Git:管理分支
我想将远程分支与 head“同步”,这样当我最终合并它时,就不会很头疼了。因此,我想尝试将头部更改拉到我的分支中,看看它有多么不同。
如何在 Git 中完成以下工作流程?
- 签出远程分支。
- 一旦我检查出来,就将更改从头脑中拉入其中。
- 编辑分支
- ,将分支(现在与 HEAD 非常相似)推送回同一分支的远程版本(不影响 head)。
任何有关完成相同任务的更好工作流程的提示都会非常有用。
I want to "sync" a remote branch up with head, so that when I finally merge it, it won't be a headache. Thus, I want to try pulling head changes into my branch to see how different it is.
How can I accomplish the following workflow in Git?
- checkout a remote branch.
- Once I check it out, pull changes from head into it.
- edit the branch some
- push the branch, which now is pretty similar to HEAD, back to the remote version of the same branch (without affecting head).
Any tips on a better workflow that accomplishes the same thing would be very useful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些都是非常基本的东西:
术语注释:
拉动是获取和合并的组合。当您使用本地分支进行操作时,无需获取,因此您进行的是合并,而不是拉取。
HEAD 的意思并不像你想象的那样。 (也许您是 cvs/svn 人员。)HEAD 只是当前签出的提交(通常通过分支名称引用)。所以你不是在合并 HEAD,而是在合并那个分支。我在这里称其为master。
至于你关于更好的工作流程来完成同样的事情的问题......嗯,这很难回答。你的目标有点模糊。你说“慢慢地”同步并指“最终合并它”,但你概述的步骤是一次性完成的,所以......好吧,它全部合并了。以后就没什么可做的了。如果您想增量地执行此操作,您可以简单地重复我给出的步骤,每次选择历史记录中的中间提交进行合并。还有一点不清楚您想要合并到哪个方向。也许您实际上想从您的分支开始,并将远程内容合并到其中?
或者使用增量合并:
This is all pretty basic stuff:
Terminology notes:
Pulling is a combination of fetching and merging. When you're operating with local branches, there's no need to fetch, so you're merging, not pulling.
HEAD doesn't mean what you think it means. (Maybe you're a cvs/svn person.) HEAD is simply the currently checked-out commit (usually referred to via a branch name). So you're not merging HEAD, you're merging that branch. I called it master here.
As for your question about better workflows to do the same thing... well, that's pretty hard to answer. Your goals are a little ambiguous. You said "slowly" sync up and refer to "finally merging it", but the steps you outline do it all at once, so... well, it's all merged. There's nothing to do later. If you wanted to do it incrementally, you could simply repeat the steps I gave, picking intermediate commits in the history to merge each time. It's also a little unclear which direction you want the merging in. Maybe you actually wanted to start from your branch, and merge remote stuff into it?
Or with incremental merges: