Now we want to create a new branch called dev from our master branch. Here is our current state of our git graph before the branching:
To create a new branch (dev), we need click "Branch" on the top menu.
Hit "Create Branch", then our git looks like this:
Let's push our new dev branch to our remote repo:
After the dev branch push, we can check our GitHub now has two branches: master and dev branches:
Committing to the new dev branch
If we want to commit a new file (myfile04.txt) to our new dev branch:
Pushing to Dev branch:
After another push:
When we want to add major feature, it's better work on a separate branch. So, we will create a new branch called feature1 from the dev branch:
After two more commits to our new feature1 branch:
Pushing feature1 branch to GitHub:
We can select current branch by double clicking a branch under "Branches" side menu. We can tell by itsbold font face.
dev branch is the current branch:
master is the current branch:
Before we do merge feature1 to dev, to make it more interesting, we want to do additional commit to devand push to GitHub:
After working on feature1 branch, now we want to merge it into dev branch. Set dev branch as the our current branch.
Hit "OK":
Now, feature1 branch merged into dev branch.
原文链接:http://www.bogotobogo.com/cplusplus/Git/Git_GitHub_Source_Tree_2_Branching_Merging.php