简体   繁体   中英

While checked out on a branch, pull from master and merge or rebase to current branch then checkout the branch

I am working on a branch, and before making the PR I checkout master, pull, then checkout my branch again then merge or rebase master to my branch, then make the PR.

Most of the time there is no merge conflicts. and if there is merge conflict I will fix it.

When there is no merge conflicts I think this can be simplified in one command, where I don't need to type the branch name too.

I can think of powershell, that can get the name of the current branch, store it in a variable then use it to do all the merge/rebase and final checkout after everything finished.

Not an expert of powershell, but pretty sure this can be done. However are there any git command chain that can do it, without me writing the branch name. All I want is to keep pressing up on powershell until i find the command and run it. Which should work in any branch.

You don't have to checkout master just pull any new commits. As long as your remote is origin you may do the following just before submitting your PR:

git fetch origin
git rebase origin/master

origin/master is a reference to the remote version of master branch (not your local one). First fetching origin insure having up to date references of remote branches.

⚠ Also, keep in mind to not confuse "local branches", "remote branches", and "local references of remote branches".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM