Common git commands

Source: Internet
Author: User

  1. through git init command to turn the specified directory into a repository that git can manage

  2. with the command git add <file> tell git to add files to the repository, you can add multiple files

  3. with the command git commit tell git to submit the file to the repository, git commit-m "Add a file"

  4. git status command

  5. git status I tell you that a file has been modified with git diff You can see what's changed

  6. HEADThe point is the current version, so git allows us to navigate between versions of history, using commandsgit reset --hard commit_id

  7. before the shuttle, usegit log You can view the commit history in order to determine which version to fallback to, --pretty=oneline parameter

  8. to return to the future, use git reflog View the command history to determine which version to return to in the future

  9. In the modification of the file, and no add, found that the changes in the wrong place, want to revert to the appearance before the change,git checkout -- fileYou can discard modifications to the workspace, and if you modify a file that has already been added to the staging area, it will revert toAfter adding to the staging area state,git checkout -- filein the command--It's important, No.--, it becomes the "Create a new branch" command, which we will encounter again in later branch managementgit checkout command.

  10. with the command git reset HEAD file You can undo the staging area changes (Unstage) and put them back in the workspace.

  11. not finished



Common git commands

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.