Git 将 origin/master 分支拉到 local/master,当在 local/develop

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16560095/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:09:51  来源:igfitidea点击:

Git pull origin/master branch to local/master, when in local/develop

gitbranch

提问by nkuhta

I work in develop branch. Sometimes, when I want to push changes to origin, git say, that there are some changes in origin/master branch.

我在开发分支工作。有时,当我想将更改推送到原点时,git 会说原点/主分支中有一些更改。

How to pull changes from remote master to local master without checkout to local master?

如何在不结帐到本地主服务器的情况下将更改从远程主服务器拉到本地主服务器?

回答by cexbrayat

If you want to update your local master without checkout, you can do :

如果您想在不结账的情况下更新您的本地 master,您可以执行以下操作:

git pull origin master:master

That will update your local master with the origin/master

这将使用 origin/master

Or, as I assume that you want to ultimately rebase your developbranch with the changes occured in origin/master, you can do a simple git fetch, that will not touch your local branches :

或者,正如我假设您希望最终develop使用 中发生的更改重新设置您的分支origin/master,您可以执行一个简单的git fetch,它不会触及您的本地分支:

git fetch

Now your origin/masteris up to date, so you can rebase or merge your local branch with these changes. For example, when you are in your developbranch :

现在您origin/master是最新的,因此您可以使用这些更改重新设置或合并您的本地分支。例如,当你在你的develop分支时:

git rebase origin/master

And your develop branch will be up to date with the changes.

并且您的开发分支将与更改保持同步。

回答by Melounek

Accepted answer will also pulls master into your actual branch.

接受的答案也会将 master 拉入您的实际分支。

git fetch
git branch -D master
git checkout --track origin/master