git commonly used commands

Posted May 27, 20201 min read

Some commands of git have been used for a long time. Every time you repeat Baidu, you don't pay attention to remembering.

Delete remote branch

git push origin --delete remote branch name to delete

Delete local branch

git branch --delete local branch name to delete
_ -dlelete can also be abbreviated as -D_

Initialize the warehouse

git init

Update local cache

git fetch --prune origin

Modify the remote warehouse address

git remote set-url origin url

Add remote warehouse address

git remote add origin url

Delete the remote warehouse address

git remote rm origin url

Back up the contents of the current workspace and save it to the git stack

git stash

Get the content of the latest stash in the git stack and restore the content of the work area

git stash pop

Head reference points to the specified commit, only moves the current Head pointer, does not change the contents of the work area and the temporary area

git reset --soft Head

The version rolls back, the Head reference points to the specified submission, and the temporary content and work content will change to the state when the specified submission

git reset --hard Head