在我的功能分支合并成主人之后我该怎么办,但我仍然继续努力? [英] What shall I do after my feature branch has been merged into master but I have continued to work on it?

查看:156
本文介绍了在我的功能分支合并成主人之后我该怎么办,但我仍然继续努力?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚意识到我的同事已将我的特性分支合并到Github的主分支中,而自从合并后,我一直在我的本地计算机上继续研究我的特性分支。现在我只有 git add 功能分支上有一些新的改变,没有 git commit 然而。



如果我在合并时立即意识到这一点,我会先拉下主人,然后创建一个新的功能分支并开始新的功能分支。



我现在该做什么?答案会有所不同,具体取决于我是否运行了 git add git commit git push



谢谢。

解决方案

所以你已经 git add - 你的更改,所以他们目前正在上演。首先,你想用 git reset HEAD取消它们。假设你是目录中的最高级别。这些文件现在都应该(最有可能)是红色的,表示有未分离的更改。



现在您可以 git存储在创建新分支时进行这些更改。 git checkout<<主分支名称>>< / code>然后 git checkout -b<<新主题分支名称>>
现在你已经有了一份干净的副本,所以让我们用 git stash pop 。现在你回到你开始的地方,所有你已经在trunk中进行的改变,你的新改变已经准备好提交。


I just realized that my coworker has merged my feature branch into the master branch in Github, while I have been continuing working on my feature branch on my local machine since his merge. Now I have just git add some new changes on the feature branch, without git commit yet.

If I realized that immediately when he made the merge, I would have pulled the master and then create a new feature branch and work on the new feature branch.

What shall I do now? Will the answer be different, depending on whether I have run git add, git commit, or git push?

Thanks.

解决方案

So you've git add-ed your changes, so they are currently staged. First you want to unstage them with git reset HEAD . assuming you are the top level in your directory. The files should all be (most likely) red now, indicating there are unstaged changes.

Now you can git stash those changes while you create a new branch. git checkout <<master branch name>> then git checkout -b <<new topic branch name>>.

You've got a clean copy of master now, so let's get those stashed changes with git stash pop. Now you're back to where you started, with all your already committed changes in the trunk and your new changes ready for commit.

这篇关于在我的功能分支合并成主人之后我该怎么办,但我仍然继续努力?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆