Common Command collection for Git

Source: Internet
Author: User

1. Switch branches: git checkout branch_name;

2. Merge branch: Switch to master First, then execute git merge branch_name;

3. Delete the remote branch:git push origin :branch-name

The space in front of the colon should not be less, the principle is to push an empty branch to the server, equivalent to delete the branch.

4. Delete local branch: Git branch-d branch_name; (-D: Mandatory Delete)

5. View remote branch: Git branch-r;

View local branch: Git branch;

View all the local and remote branches: git branch-a;

6. Push the local branch to the remote as Master branch: Git push Origin branch_name;

Git push Origin branch_name:branch_name;

7. Get the remote branch git checkout-b branch_name origin/remote_branch_name;

Local modification of the acquired remote branch is pushed to the remote corresponding branch: Git push Origin remote_branch_name;

(If you are git pull prompted "No tracking information", the link relationship between the local branch and the remote branch is not created,

With the command git branch --set-upstream branch-name origin/branch-name . )

8. Create a branch: Git branch branch_name;

Switch branches: git checkout branch_name;

Create and switch branches: git checkout-b branch_name;

Merge a branch to the current branch:git merge <branch_name>;

Common Command collection for Git

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.