Common git branch management commands

Source: Internet
Author: User

View local branches

 
Git Branch * Dev master

* Indicates that the current Dev branch is located.

View remote branches

 
Git Branch -- remote origin/dev origin/Master

View All remote and local branches, with the-A PARAMETER

 
Git branch-A * master remotes/ORIGIN/head-> origin/Master remotes/ORIGIN/develop remotes/ORIGIN/issue_193

Create Branch

 
Git checkout-B new_branch

Note: new_branch'sCodeFrom current Branch

Switch Branch

 
Git checkout another_branch

It is different from creating a branch-parameter B

Push local branch code to remote server

 
Git push origin branch_name

If the remote server does not have this branch, it will automatically create

Pull remote branch code to local branch

 
Git pull origin branch_name

To delete a local branch, you must switch to another branch before deleting a branch.

 
Git checkout bgit branch-D

Delete remote Branch

 
Git push Origin -- delete branch_name

Merge local branches

 
Git merge B

If the current branch is Dev, the above command is to merge the local B branch code into the current branch Dev.

Merge remote branches, which is almost the same as the previous one,

 
Git merge origin/B

The remote branch B is merged into the current local branch Dev.

Let's get a fine-grained merge. If my current branch is develop and I want to transfer build. LSP merge in a branch to the develop branch, what should I do? Checkout!

 
Git checkout a build. LSP

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.