Git: How to create new branch, work on it then merge with main?
2 replies, posted
Hey, I am using Eclipse with Egit and Bitbucket git.
Me and 3 other people are working on same (main branch called Master), I wish to create new branch and work on it, it has to be slightly modified than the rest of the project. Basically I am main coder in group and my team is falling behind, I am gonna start working on their bits a bit but I don't want to work on them and then end up them re-writing them. + I need to modify main code a bit. So I want to create new branch.
I have no idea how though, how can I create a branch, like clone all master branch, work on it then at later stages merge with it.
How do I do it? I tried clicking create new branch in Eclipse, but that screwed something up.
You type "git checkout -b new_branch" to create and checkout to a new branch. Commit on that branch, then when you're done, switch to master ("git checkout master") and do "git merge new_branch". It will merge the commits from the new branch to your master. Once that's done, push your commits.
Just a side note; it's good to get in the habit of branching for major features.
Branch every time you want to add significant amounts of code that interact with other functions and you will save yourself a lot of headaches the next time you break the entire thing. Roll back and you're golden.
Sorry, you need to Log In to post a reply to this thread.