使用 git,如何将跟踪分支合并回远程源/HEAD?
我让自己陷入了本地仓库的混乱之中。 长话短说,我有一份副本远程仓库的;我在本地存储库中创建了一个名为“my_branch”的分支;我曾多次承诺工作。然后我将分支推送到远程仓库。这是我的本地存储库图...(因为我已将 my_branch 推送到远程,这也是远程的样子)。
--C0--------------C4-- (local master)
\
--C1-C2-C3-- (local my_branch)
然后我决定尝试重新建立基础,但我想我完全搞砸了。我还尝试执行 git reset --hard ,我想我又损坏了我的本地存储库。所以我决定从一个干净的地方开始。我从远程存储库中获取了 my_branch 以下。
然后我从远程检查了 origin/my_branch 。 (我现在看到我的 GUI 工具 GitX 中有一个“分离的 HEAD”。)现在...如何将此分支与远程上的 origin/HEAD 又名 origin/master 合并?
I got myself into a little bit of a local repo mess. Long story short, I had a copy of a remote repo; I created a branch called 'my_branch' in my local repo; I committed work a few times. I then just pushed the branch to the remote repo. Here's my local repo diagram...(since I've pushed my_branch to the remote, this is what remote looks like too).
--C0--------------C4-- (local master)
\
--C1-C2-C3-- (local my_branch)
I then decided to try to rebase, but I think I totally messed up. I also tried to do git reset --hard
and I think I corrupted my local repo some more. So I decided to start from a clean place. I grabbed my_branch from the remote repo following this.
I then checked out origin/my_branch from remote. (I now see that I have a "detached HEAD" in my GUI tool GitX.) Now...how do I merge this branch with origin/HEAD aka origin/master on remote?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您要跟踪工作的位置创建一个分支
现在您可以查看其他分支并合并或重新设置它们的基础。
要获取您尚未跟踪的远程分支的本地分支:
现在只需上推分支即可。您很可能需要用力推动
Make a branch right where you are to get that work tracked
Now you can check out other branches and merge or rebase them.
To get a local branch for a remote one that you are not tracking yet:
Now just push up the branches. Most likely you will require a force push