Basic commands

  • git help <command>: Obtain help information about the git command
  • git initCreate a new Git repository whose data will be stored in a repository named.gitThe directory
  • git status: Displays the current warehouse status
  • git add <filename>: Adds a file to the staging area
  • git commit: Creates a new commit
    • How to write good submission information
    • Why write good submission information
  • git log: Displays historical logs
  • git log --all --graph --decorate: Visual history (directed acyclic graph)
  • git diff <filename>: Displays the difference with the staging area file
  • git diff <revision> <filename>: Displays the differences between two versions of a file
  • git checkout <revision>Update:HEADAnd the current branch

Branch and merge

  • git branch: Display branch
  • git branch <name>Create a branch
  • git checkout -b <name>: Creates a branch and switches to it
  • The equivalent ofgit branch <name>; git checkout <name>
  • git merge <revision>: merges to the current branch
  • git mergetool: Use tools to handle merge conflicts
  • git rebase: Rebase a series of patches to the new baseline

The remote operation

  • git remote: Lists the remote end
  • git remote add <name> <url>: Adds a remote device
  • git push <remote> <local branch>:<remote branch>: transmits the object to the remote end and updates the remote reference
  • git branch --set-upstream-to=<remote>/<remote branch>: Creates an association between the local and remote branches
  • git fetch: Retrieves an object/index from a remote end
  • git pull: the equivalent ofgit fetch; git merge
  • git clone: Downloads the repository from the remote end

undo

  • git commit --amend: Edits submitted content or information
  • git reset HEAD <file>: Restores temporary files
  • git checkout -- <file>: Discard modification

Git Advanced Operations

  • git configGit is a highly customizable tool
  • git clone --depth=1: Shallow Clone, which does not include complete version history information
  • git add -p: Interactive temporary storage
  • git rebase -i: Interactive rebasing
  • git blame: View the last person to modify a row
  • git stash: Temporarily removes the modified contents from the working directory
  • git bisect: Searches history by binary lookup
  • .gitignoreFiles: Specifies files that are intentionally not tracked