当您git pull在master分支上运行时,它通常从origin/master. 我在另一个名为 的分支中newbranch,但我需要运行一个执行git pullfrom origin/masterinto的命令,但在拉取完成之前master我无法运行以更改所选分支。git checkout有没有办法做到这一点?
为了提供一些背景知识,存储库存储了一个网站。我newbranch通过将网站切换到newbranch. 现在这些更改已在上游合并到master分支中,我也在尝试将网站切换回master分支。在这一点上,newbranch和origin/master是相同的,但是master落后origin/master并且需要更新。问题是,如果我以传统方式进行操作:
$ git checkout master
# Uh oh, production website has now reverted back to old version in master
$ git pull
# Website is now up to date again
我需要实现与上述相同的 ( git checkout master && git pull),但在此过程中无需将工作目录更改为较早的版本。