Category |
Specific commands |
Local submission |
Initialize the Repository: git init |
Add the file to the repository: git add filename |
Submit the file to the repository: git commit-m "message" (temporary storage area) |
Delete the file from the Repository: git rm filemame + commit |
View the status of the staging area: git status |
Undo the local modification: git checkout -- filename |
Undo the modification of the temporary storage area: git reset HEAD filename |
View the differences between the workspace and the temporary storage zone: git diff |
View the differences between the staging area and the Repository: git diff -- cached |
View the differences between the workspace and repository: git diff HEAD |
View history: git log (-- pretty = oneline optional parameter) |
Roll back the local file to the specified version: git reset -- hard version_number |
Roll back the local file to the previous version: git reset -- hard HEAD ^ |
View Command records: git reflog |
Branch Operations |
Create branch: git branch dev |
Create and switch to the branch: git checkout-B dev |
Switch branch: git checkout master |
Delete branch: git branch-d dev |
Merge with current branch: git merge dev |
View branch: git branch |
Remote warehouse operations |
Create an SSH Key: ssh-keygen-t rsa-C "youremail@example.com" |
Clone from remote database: git clone git @ link/file. git (a local repository is automatically created after cloning) |
View the associated remote Repository: git remote-v (add v to display the address of the remote repository) |
Pull and merge from remote Repository: git pull origin dev |
Obtain and merge from a remote Repository: git fecth origin dev + git merge origin/branch |
Push local repository content to the associated remote: git push origin master (master is the current Branch) |
Associate a remote repository with a local repository: git remote add origin git @ link/file. git (origin is not a fixed value) |
Set the association between local branches and remote branches: git branch -- set-upstream-to origin/dev |
Stash operation |
Storage "work site": git stash |
View the stash region: git stash list |
Restore stash content: git stash apply stash_number |
Delete stash content: git stash drop stash_number |