Some common operations commands for git

Source: Internet
Author: User

These operation commands are from Liaoche Teacher's official online to see the PostScript down, the following is the official website of Liao Xuefeng Teacher, we can see, tutorials good ~http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 

1. Install Git on Windows

: http://msysgit.github.io/default installation is available, open Git->git Bash after installation is complete 2. Configure the user name and password 3.git InitTurn the current directory into a repository that git can manage, (PWD view current directory) 4. Submit file Readme.txt to Repositorygit add Readme.txt (add File Readme.txt to staging area)git commit-m "Add Readme" (Submit the contents of the staging area to the repository and use-M "" To add the submission instructions) 5.git StatusCheck the status of the current warehouse, including whether there are files modified, or there are no submissions added to the staging area 6.git diffTo view the difference between a file in your local workspace and a file in the current repositorygit diff HEAD--readme.txt: You can see the difference between the latest version in the workspace and the repository 7. View the submitted loggit log (logs submitted from near to far)git log--pretty=oneline (one line displays the log)git log graph--pretty=oneline (show chart, you can see merge branches, etc.)git reflog:git log can only see the log in the currently open bash and want to see the log of bash that was previously opened, you can use this command to view all log 8. Jump versioneach commit will have a commit ID, which can be seen in Git log, with head pointing to the current version in GitBacktrack to previous version: Git reset--hard head^Back to the 2nd version: git reset--hard head^^ (go back to the first few, add a few ^)you can also use git reset--hard head~100 (for backtracking to the previous 100th version)version jump with commit ID: git reset--hard XXXX (XXX is commit ID) 9. Undo Changesgit checkout-file: Discard workspace Changes (A: Staging area no content, restore to the same version of the repository. B: Has been added to staging area, restored to the same as in staging area)git reset HEAD file: Undo the changes in the staging area and re-put them back in the workspace 10. deleting filesgit rm fifle: (delete a file from your local workspace)git commit-m "Remove file": (Commit delete action)If you delete it, you can restore it locally from the repository using this operation: Git checkout--file 11. Connect to the remote repository1)the. SSH directory is added to the home directory with Id_rsa and id_rsa.pub two key files2) Register your GitHub account and click "ADD SSH Key". Paste the contents of the Id_rsa.pub in key. (Proof that the user is allowed to submit files)3) Create an empty warehouse called Learngit on GitHub4) Add a remote repository locally: Git Remote add Origin https://user:[email protected]/metian1990/ Learngit.git (replace user and password with your own git account username and password to change meitian1990 to your own GitHub account name)5) Clone a library to local: Git clone git remote add Origin https://user:[email Protected]/metian1990/learngit.git6) View Remote Library informationgit remote: (View remote library information)git remote-v: (View detailed remote library information)7) Push Branchgit push Origin master: (pushes content from the master branch locally to the remote Library origin)8) Git Pull: (from a remote crawl branch) 12.git Checkout-b DevCreate Branch Dev, equivalent to the following two commands:git branch Devgit checkout dev 13.git Checkout Master: (cut back to master branch) 14.git Merge Dev: (merge branch dev to current branch)This must be successful if the current branch and Dev are not in conflict (if both the current branch and Dev commit changes to the same file and commit, there will be a conflict, the workaround is to manually modify the file to be consistent before merging) 15.git branch-d Dev: (delete branch dev) 16.git Stash: (Save workspace)git stash list: (View all currently saved workspaces) 17.git Stash Pop: (reverts to the workspace and removes the workspace)equivalent to the following two commands:
git stash Applygit stash Drop 18.git branch-d Dev: (forcibly delete branch dev) 19.git Tag v1.0: (Label the current branch v1.0)git tag: View all tags in the current repositorygit Show v1.0: (view tag information for label v1.0) 20.git tag-d v1.0: (Remove label v1.0) 21.git Push Origin v1.0 (pushes a branch labeled v1.0 to the Remote library origin)git push Origin--tags: (Push all the tabs that are not pushed all at once) 22. Delete Remote Tagsgit tag-d v1.0: (delete local Tag v1.0 first)git push origin:refs/tags/v1.0: (again removed from remote)

Some common operations commands 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.