Some simple git usage

Add

git add .

Rm

git rm --cache   # rm from git 
git rm --f  # rm from disk

Config

git config -l
git config --global http.proxy http://127.0.0.1:8080

Remote

git remote add 
git remote -v # show remote information
git remote rm 

Branch

git branch   # new a branch
git branch -d 

Checkout

git checkout 
git checkout -b 

Switch

After git v2.23, a new version of checkout comes. The “switch” command provides a simple alternative to “checkout”.

git switch 
git switch -c 

merge

git checkout main
git merge dev # merge dev to main

rebase

git rebase
gir rebase -i 

reset

git reset HEAD~ # git reset HEAD~2
git reset HEAD^

revert

Used for remote branch.

git revert HEAD~ # git revert HEAD~2
git revert HEAD^

cherry-pick

git cherry-pick /

你可能感兴趣的:(git)