如何将本地 Git 分支推送到远程的 master 分支?
我的本地存储库中有一个名为development的分支,我想确保当我将其推送到origin时,它会与origin/master合并。目前,当我推送时,它会添加到远程开发分支。
我该怎么做?
I have a branch called develop in my local repo, and I want to make sure that when I push it to origin it's merged with the origin/master. Currently, when I push it's added to a remote develop branch.
How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您还可以通过这种方式隐式引用前一个分支:
You can also do it this way to reference the previous branch implicitly:
作为 @Eugene 答案的扩展,另一个版本将致力于将代码从本地存储库推送到 master/develop 分支。
切换到分支“master”:
从本地存储库合并到master:
推送到master:
As an extend to @Eugene's answer another version which will work to push code from local repo to master/develop branch .
Switch to branch ‘master’:
Merge from local repo to master:
Push to master:
或者,更一般地说
or, more generally
正如人们在评论中提到的那样,您可能不想这样做......
如果您知道自己在做什么,那么 mipadi 的答案绝对正确。
我会说:
As people mentioned in the comments you probably don't want to do that...
The answer from mipadi is absolutely correct if you know what you're doing.
I would say:
您可以安装 git 工具 https://git-scm.com/downloads 它可以帮助合并分支到master。我在 RStudio 中创建了一个分支,对其进行处理,并将更改推送到 github。然后,当我想要合并时,我打开了这个 git GUI 工具,导航到包含我的存储库的文件夹,然后将分支合并到 master。我打开 RStudio 检查是否发生了更改,然后从 RStudio 推送到 github。
you can install the git tool https://git-scm.com/downloads and it can help with merging branch to master. I created a branch in RStudio, worked on it, pushed changes to github. Then when I wanted to merge I opened this git GUI tool, navigated to the folder with my repository, then merged the branch to master. I opened RStudio to check if the changes had happened, then pushed to github from RStudio.
让我们将其自动化为一个简单的
git Push
。Let's automate this down to a simple
git push
. ????Example: local branch
develop
should push toorigin/master
:Set the branch's remote (this has likely already been done)
Set the remote's push mapping