- git checkout master- git pull- git checkout your-feature-branch- git merge master //resolve conflicts if any and commit- git push
2:如果您想将更改重新建立在main之上。
git checkout master #Switch to main branchgit pull #Take latestgit checkout your-feature-branch #Switch to story branchgit pull --ff-only # Ensure branch is up to dategit rebase -i origin master #Interactively rebase your commits on top of master. So your changes are on top of latest commits in main.git rebase --continue #Resolve conflicts and rebase --continue to continue with next commitsgit push -f origin your-feature-branch # As you have rewritten the commit history, you have to **force push** the commits
currentBranch=$(git rev-parse --abbrev-ref HEAD) # gets your current branch(needed for point 4)git checkout master # checks out mastergit pull # gets latest changes from mastergit checkout $currentBranch # checks out the in point 1 saved branchgit merge master # merges your current branch with master