Git-Summary of Common Operations

Source: Internet
Author: User
Tags saltstack

Tag: git

Remote warehouse commands

Check out Repository: $ [email protected]: yaoxiabing/saltstack. Git
View remote Repository: $ git remote-V
Add a remote Repository: $ git remote add [name] [url]
Delete a remote Repository: $ git remote RM [name]
Modify the remote Repository: $ git remote set-URL -- push [name] [newurl]
Pull remote Repository: $ git pull [remotename] [localbranchname]
Push remote Repository: $ git push [remotename] [localbranchname]


Branch commands

View local branches: $ git Branch
View remote branches: $ git branch-R
Create a local branch: $ git branch [name] ---- note that the new branch will not automatically switch to the current branch after it is created
Switch branch: $ git checkout [name]
Create a new branch and immediately switch to the new branch: $ git checkout-B [name]
Delete branch: $ git branch-d [name] -----D option can only delete the branches that have already joined the merge operation. To force delete a branch, use the-D option.
Merge branch: $ git merge [name] ---- merge the branch named [name] with the current Branch
Create a remote branch: $ git push origin [name]
Delete a remote branch: $ git push origin: heads/[name] or $ git push origin: [name], for example: [[email protected] saltstack] # git push Origin -- delete 123 # delete a remote Branch


Example1: Submit a local branch origin2 to the remote warehouse and use it as the master branch of the remote warehouse or as the branch named 123

[[Email protected] saltstack] # git branch origin2 # create a local branch origin2
[[Email protected] saltstack] # git push origin origin2: 123 # submit the local origin2 branch as the remote 123 Branch
[[Email protected] saltstack] # git push origin origin2: master # submit the local origin2 branch as the remote master Branch


Example2: delete a local branch that does not correspond to a remote Branch

[[Email protected] saltstack] # git fetch-P # Delete the local branch that does not correspond to the remote branch after fetch


In the future, we will continue to add...


Reference link:Http://blog.chinaunix.net/uid-9398085-id-3164754.html

Http://zengrong.net/post/1746.htm


This article is from the "the-way-to-cloud" blog, please be sure to keep this source http://iceyao.blog.51cto.com/9426658/1560202

Git-Summary of Common Operations

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.