Git Command Summary

Source: Internet
Author: User
Tags using git version control system

Git is a very powerful distributed version control system. Learn Git can refer to Http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/ 001373962845513aefd77a99f4145f0a2c7a7ca057e7570000

Liaoche teacher wrote the tutorial. Remember the commands you use most often, and learn more about git in your daily routines. Here are some of the frequently used commands that I've summed up from the Liaoche Teacher's tutorial.

git command summary: 1. Initialize a git library: git init2. Submit the file to the GIT library:    git add  file name (can have multiple)      git commit -m "Information" 3. View the status of the workspace: git status    // Tell you which files were modified or ready to submit 4. View the contents of the file being modified:    git diff  filename  5. View the Commit history (you will see the historical version ID of the submission):     git log     Simplified Output submission history: git log --pretty= Oneline6. Return to the historical version (HEAD for the current version, hean^ for one by one versions):    git reset --hard head^       //back to previous version     git reset --hard  historical version id   //back to historical version 7. View History command: git reflog      //can be used to determine which version of the "Future" is returned 8. Undo Changes:     a. Discard modifications in the workspace:git checkout --  file name      B. Files submitted to staging area, but not submitted to the repository, want to undo the modification of the file:git reset     head  filename      //file will be re-returned to workspace 9. delete file:     a. Delete only the workspace:rm  file name  &nbsP;  b. Remove the:git rm --cache   file name from the staging area 10. Working area Delete files deleted by mistake:    git  checkout --  file name       //deletion is also a modification, so with                   discard files in the workspace Modify command is the same 11. Associate a remote library: git remote  add origin [email protected]:p ath/repo-name.git     //where [email  protected]:p Ath/repo-name can be copied on the interface to add remote libraries 12. Push Branch:     All content for the first time to push the master branch: Git push  -u origin master     Push changes:     git push origin  master13. Cloning a remote library (the remote library address can be copied on its own account):git clone  remote Library address 14. Create and merge Partitions:     view branches: git  branch     Create branch:git branch  branch name      Toggle Branch:git  checkout  Branch name      Create and Switch branch:git checkout -b  branch name      Merges a branch to the current branch:git merge Branch name to merge      Delete branch:git branch -d  branch name      Force deletion of partitions that have not yet been merged: git  branch -D  partition name 15. View Branch Merge diagram: git log --graph16. Common mode merge, which is the merge history that can be seen after merging: git merge - -no-ff -m "description Information"   The branch name to          merge 17. Save on-site:git stash     Recovery Site:git stash pop    There is another way to recover the site: using git stash apply  recovery, But the content in stash is not                    is deleted, if need to delete, also use GIT STASH DROP18. View Remote Library information:git remote  (see more details using the-v  option) 19. Commits a partition (pushes all local commits for that branch to the remote library):git push origin  branch name     If push fails, use git  Pull crawl remote Latest commit 20. Label:     View all Tags:git tag     tag (default is for latest submissions):       git tag  tag name       tag History submitted version: git  tag  Tag name   submitted id     view aTag information:     git show  tag name      push a tag to the remote library:     git push origin  tag name      push local tags at once:     git  push origin --tags     Delete Tags:     git tag -d   Tag name      remove tags for remote libraries: git push origin :refs/tags/tag name.

With these commands in hand, it is convenient to use Git to manage code and co-development in future development.

This article is from the "June Feng Eureka" blog, please be sure to keep this source http://10274409.blog.51cto.com/10264409/1773942

Git Command Summary

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.