Git common commands

cloneCode: git clone code address
Set the user name: git config — global user. name “marin” and the GIT config — global user. name command is used to view
Set mailbox: git config –global email “984482955@qq.com”
Check all git –list to see all the contents.
View file git status added or modified in branch state
Add the newly added or modified files to the cache git add file name or git add.
Adding cached files to the online version library git commit pops up a notepad for writing and submitting annotations
Or git commit -m “I want the annotation content”.

Withdraw: git reset HEAD filename

Chain command: git commit -a -m “submitted notes”
View submission history: git log

Comparison order:
The difference between workspace files in cache files is git diff
Comparison between cache and version library git diff –cached or git diff –staged
Comparison between workspace and version library git diff master

Cancellation order:
Withdraw from cache to workspace git reset HEAD flie.name
Restore workspace git cheakout – file.name
Revoke the last submission operation git commit -m “who and who will submit together, anyway Annotation” –amend

Delete operation:
Delete the file in the cache (the file in the workspace must be deleted first, or it won’t work):git RM file.name
Delete cache and workspace files: git RM -f file.name
The cache and workspace have files to delete the cache files: git RM –cached file.name

Restore order:
Restore files: git checkout commit.id file.name
Recovery Version: git reset –hard commit.id
Revert to the previous version: git reset –hard HEAD^
Revert to the specified version: git rteset –hard HEAD~2
Restore to the current version: git reflog // can view each commit. ID and then use: git reset — hard commit.id.

View the name of remote warehouse: git remote
Modify the name of remote repository: git remote add
View the address of remote warehouse: git remote -v
Submit files to remote repositories: git push warehouse name master (Branch)

Update local code:
git fetch Pull down and do not merge.
perhaps

git pull Pull down and merge.
Multi player collaboration in conflict resolution:
1.git fetch
2.View different git diff master origin/master
3.Manually merge git merge origin/master
4.HEADThe code under the pointer is written by oneself, which is good if he is afraid of not breaking it. Then he keeps the good and submits it.

Leave a Reply

Your email address will not be published. Required fields are marked *