Commands commonly used by git ----- (commonly used in work)

Create repository

git clone 'url' #Clone the remote repository

git init #initialize the local repository

Modify and submit 

git status #View status 

git diff #View changes

git add . #Track all changed files

git add <file> #Track the specified changed file

git mv <old> <new> #file rename

git rm <file> #delete file

git git rm --cached <file> #stop tracking files but do not delete

git commit -m "commit message" #Submit all new files

git commint --amend #Modify the last commit       

 View commit history

git log #View commit history

git log -p <file> # View the commit history of the specified file

git blame <file> #View the commit history of the specified file in a list  

revoke 

git reset --hard HEAD #Undo all uncommitted file modifications in the working directory

git checkout HEAD <file> #Undo the modification of the specified uncommitted file

git revert <commit> #Undo the specified submission  

the branch 

git branch # View the current branch

git branch -a #View all branches

git checkout -b dev #Create a new branch and switch to the new branch

git push origin dev:dev # Push the local branch to the remote branch

git checkout -b newbranchname origin/originbranchname #Create a new branch based on the remote existing branch

git branch --set-upstream-to=origin/dev #Associate the local branch with the remote branch:

git branch -d dev #delete local branch

git push origin --delete dev #delete remote branch

git merge <branch> #Merge the specified branch into the current branch  

remote push

git push -u origin master #submit code 

 

おすすめ

転載: blog.csdn.net/qq_60976312/article/details/131247760