git merge [branch-name] Merge a branch into the current branch, which will merge the merged branch and your current branch’s commit together to form a new commitgit rebase [branch-name] Merge a branch into the current branch, putting your current branch’s commit at the end of the merged branchgit rebase -i HEAD~[num] merge the last num commits into one (so that there is only one commit after pushing to the remote repository, avoiding contaminating the remote commit)git pull --rebase is equivalent to git fetch + git rebasegit checkout <branch-name> [--] <file-name> pulls the current file from a different branchgit checkout --theirs [file-name] means check out the other branch, i.e. save the changes from the other branch and discard the changes from the current branch. In case of conflict, use someone else’s code directlygit checkout --ours [file-name] Check out the current branch, i.e. save the changes in the current branch and discard the changes in the other branch. Use your own code directly in case of conflictsgit cherry-pick <commit-id1> <commit-id2> ... Merge some of the specified commits into the current branchgit cherry-pick <branch-name> Move the most recent commits from the selected branch to the current branchgit checkout dev
git rebase master
#or git merge master
#or git cherry-pick 8797a4f
#or git merge master #or git cherry-pick
git add .
#continue to modify the merge
git rebase --continue
#or git merge --continue
#or git cherry-pick --continue
#If you don't want to merge, just terminate
git rebase --abort
#or git merge --abort
#or git cherry-pick --abort
git merge and git rebuild
Use merge for public branches, rebase for personal branches
local and remote branches are the same, use rebase instead of merge