git:如何更新main分支

fetch - Download objects and refs from another repository

1
git fetch --prune --all
1
2
git switch main
git fetch [origin] [main]
1
git fetch origin main:main

pull - Fetch from and integrate with another repository or a local branch

1
2
3
git switch main
git pull [origin] [main]
git pull --rebase

merge - Join two or more development histories together

1
2
git switch main
git merge origin/main

rebase - Reapply commits on top of another base tip

1
2
git switch main
git rebase origin/main
1
git rebase origin/main main
1
2
3
git rebase --onto <newbase> <upstream> <branch>
# <newbase> default: <upstream>
# <branch> default: HEAD

branch - List, create, or delete branches

1
git branch main

switch - Switch branches

1
git switch -c main

restore - Restore working tree files

checkout - Switch branches or restore working tree files

1
git checkout main

reset - Reset current HEAD to the specified state

1
2
git switch main
git reset origin/main