Git view, create, delete local, remote branch

Source: Internet
Author: User

1. View Remote Branch
Git branch-r
Origin/master
2. View local Branch

*master

Note : The local branch where the current is located is indicated by *

3. View local and remote branches
Git branch-a
*master
Remotes/origin/master
4. Create a branch

4-1 Creating a local branch

-a* master  test_1  remotes/origin/master

Note : When you create a local branch, the default is to copy something from your local branch to the newly created local branch.

4-2 push local branch to remote as remote branch

$ GIT push origin test_1to [email protected]****** * [New branch]      test_1-a* mast Er  test_1  remotes/origin/Master  remotes/origin/test_1

Note : Git push Origin test_1 will push the local test_1 branch to the far end, the local test_1 branch and the remote counterpart are test_1-->test_1

If there is no local branch test_9, the push will prompt the error

5. Switch to the branch
' test_1 '
6. Delete local Branch
$ git branch-a  master  test_1  test_2  remotes/origin/Master  remotes/origin/ test_1  remotes/origin/--a  master  test_1  remotes/ origin/Master  remotes/origin/test_1  remotes/origin/test_2

You can see that the local branch test_2 deleted

7. Delete Remote Branch
$ git branch-a* master  test_1  remotes/origin/Master  remotes/origin/  Test_1  remotes/origin/test_2$ git push origin:test_2to [email protected]*********- [ Deleted]         test_2-a* master  test_1  remotes/origin/  Master  Remotes/origin/test_1

Note : Git push Origin:* * * is to delete the remote branch meaning, and just i delete the local unrelated. As below, I keep the local test_1 branch, just delete the remote branch test_1

$ git push origin:test_1to [email protected]********- [deleted]         -a* master  Test_1  remotes/origin/master

Git view, create, delete local, remote branch

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.