Git branch management

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.