First, create the dev branch and switch to the dev branch.
$ git checkout -b dev
Git checkoutAdd the-B parameter to the command to create and switch, which is equivalent to the following two commands:
$ git branch dev$ git checkout dev
Then, use
Git Branch Command to view the current Branch:
$ git branch* dev master
The GIT branch command lists all branches. A * sign is marked before the current branch.
Then we can submit the file normally on the devsub-branch, such as creating a new hello.txt file.
Submit
$ git add hello.txt$ git commit -m "add hello"$ git push -u origin dev
Now that the dev branch is complete, go to GitHub.
Dev Branch
Master Branch
The test environment is as follows: in the Local warehouse, we first submit the content to the remote warehouse with the master branch, then switch the branch Dev to submit the modification content to the remote warehouse.
We found that the content of hello.txt on dev's sub-branch is Hello git Dev and switched to master's sub-branch. The content of hello.txt is still Hello git
Now we merge the dev Branch's work results into the master branch.
$ git merge devUpdating 50bca6c..ee88faaFast-forward WebRoot/hello.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Git mergeCommand to merge the specified branch to the current branch. After merging, view the hello.txt content on the master branch, which is exactly the same as that on the dev branch.
After merging, you can delete the dev branch.
$ git branch -d devDeleted branch dev (was ee88faa).
After deletion, check branch, and only the master branch is left:
$ git branch* master
Note: The local branch is deleted. The remote branch is deleted as follows:
$ git push origin :dev
Prompt to enter the user name and password.
Summary:
View branch: git Branch
Create branch: git BranchName
Switch branch: git checkoutName
Create + switch branch: git checkout-BName
Merge the specified branch to the current branch: git mergeName
Delete branch: git branch-dName
Note: name indicates the branch name.
Itmyhome
Source: http://blog.csdn.net/itmyhome1990/article/details/39929199
Git branch management