Git configuration

Check the configuration

git config –list

Change your username and email address

Git config –global –replace-all user.name git config –global –replace-all user.name

Git config –global –replace-all user.email

Generate a Git secret key. (Replace it with your own email address)

ssh-keygen -t rsa -C “[email protected]

Git cut account directive

ssh-add ~/.ssh/sunland_id_ras

ssh-add ~/.ssh/id_rsa

Git operation

Zero: Git region interpretation.

Git is divided into three parts: workspace, staging area and repository. 1. The area for writing code is the workspace.

2. The content after add enters the temporary storage area.

3.com.mit after the code into the version library. Then it can be pushed to the remote warehouse.

1. Branch related instructions

Git branch Check the local branch

Git branch -a looks at all branches, including remote branches

Git branch -r Displays remote branches

Git checkout -b branch01 — git checkout -b branch01 — git checkout -b branch01

Git checkout branch01

Git branch -d branch01 delete branch branch01

Git branch -d branch01 git branch -d branch01

2. Code addition and deletion submit related instructions

1, git status check the current branch, the modified code

Git add adds code to the staging area

Git commit -m — “amend” — “amend” < does not increase the number of commit ids, but will modify the current commit ID >

(2), git commit – change the commit amend / / no information, not to increase the commit id number, but to modify the current commit id

Git reset commit reverses the code that the add command added to the staging area and returns to the workspace.

Git fetch is a remote host name that pulls the latest content from the remote host to the local host

The branch name is used to pull down the latest content of the remote host and merge it directly

The branch name pushes its own code to the remote host

Git cherry-pick commit synchronize the version number of the commit to the current branch

Git reset COMMIT restores all changes made after this release to the workspace and clears all commit numbers in between. Don’t use hard, don’t use hard. > Then add and commit. You can reduce the COMMIT number.

A branch merge conflict occurred

Git merge –abort (This attempts to reset your working copy to its pre-merge state. This means that it should recover any uncommitted changes from before the merge, although it cannot always reliably do this. In general, you should not merge with uncommitted changes.

Git Checkout

Git reset –merge Git merge –abort # If git version >= 1.7.4, git reset

The code to recover

Git reset HEAD restores all files in the staging area to the workspace

Restore the specified file in the staging area to the workspace: git reset HEAD ZXCVB

ZXCVB represents the full path of the file

Restore all files in the workspace to staging: Git checkout.

Restore the workspace specification file to staging: git Checkout ZXCVB

ZXCVB represents the full path of the file