Common operations of git

 

1.git initialization

  •     git init

2. Add files

  •     git add filename

3. Submit

  •     git commit -m "comment"

4. Check the status 

  •  git status
  •  git status -s abbreviated instructions

5. Recovery operation

  • git reset HEAD, the directory tree in the staging area will be rewritten and replaced by the directory tree pointed to by the master branch, but the workspace will not be affected
  • git rm --cached <file> will delete the file directly from the staging area, the workspace will not change
  • git checkout  . or git checkout -- <file> will replace the files in the workspace with all files in the staging area or the specified files. This operation is very dangerous and will clear the changes in the workspace that have not been added to the staging area.
  • git checkout HEAD . Or git checkout HEAD <file> , all or part of the files in the master branch pointed to by HEAD will replace the files in the staging area and the work area, which is also very dangerous
  • git reset --hard HEAD^ HEAD^ represents the parent commit of HEAD. This command is equivalent to resetting the master to the previous old commit. (The --hard parameter will destroy uncommitted changes in the workspace )
  • git reset --hard 9e8a761

 

  • git reset -- filename only removes the changes of file filename from the temporary storage area, and other changes in the temporary storage area remain unchanged, which is equivalent to the reverse operation of git add filename.
  • git reset HEAD filename same as above

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324418575&siteId=291194637