简体   繁体   English

功能分支合并到master后,我会继续做什么呢?

[英]What shall I do after my feature branch has been merged into master but I have continued to work on it?

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. 我刚刚意识到我的同事已将我的功能分支合并到Github的master分支中,而自从他合并以来,我一直在我的本地计算机上继续从事我的功能分支。 Now I have just git add some new changes on the feature branch, without git commit yet. 现在我只是git add在feature分支上git add一些新的更改,还没有git commit

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 ? 答案会有所不同,具体取决于我是否已运行git addgit commitgit push

Thanks. 谢谢。

I am not confident with rebase or git in general yet. 我对总体上的rebase或git还是没有信心。

Remember, you can always just make a copy of your repository and try things out there without worrying about mucking things up. 请记住,您始终可以只复制存储库并在那里进行尝试,而不必担心将其存储起来。 In fact, if you are running commands you're not familiar with recommended by people you don't know, this is probably a good idea in general. 实际上,如果您正在运行不熟悉的人推荐的命令,那么通常这是个好主意。

Could you give specific commands for me to try? 您能给我一些具体的命令吗?

First, make sure you have an up-to-date copy of the remote repository: 首先,请确保您拥有远程存储库的最新副本:

git remote update

Next, make sure you are on your feature branch: 接下来,确保您在功能分支上:

git checkout myfeature

And finally, rebase onto the updated master branch: 最后, rebase到更新的master分支:

git rebase origin/master

Depending on the changes in master since you created your feature branch you may need to perform some conflict resolution. 自创建功能分支以来,取决于master的更改,您可能需要执行一些冲突解决方案。 If the only changes was that your feature branch was merged, you shouldn't have to correct anything. 如果唯一的更改是您的功能分支已合并,则您无需进行任何更正。

(Note that the above assumes you are working with a remote named origin , which is common but not guaranteed.) (请注意,以上假设您使用的是远程命名origin ,这很常见,但不能保证。)

You can git stash those changes while you create a new branch. 您可以在创建新分支时git stash这些更改。 git checkout <<master branch name>> then git checkout -b <<new topic branch name>> . git checkout <<master branch name>>然后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 . 您现在已经拥有一个完整的master副本,因此让我们使用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. 现在,您回到了开始的位置,所有已提交的更改已在主干中,新的更改已准备好提交。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果我将工作合并到主数据库但没有推送后,有人将新提交提交到git存储库的主数据库,该怎么办? - What shall I do if someone pushed new commits to master of git repository after I merged my work to master but didn't push? 在功能分支工作期间我该怎么办,如果不将master合并到功能分支就无法编译我的项目? - What shall I do in the middle of working on a feature branch, and can't compile my project without pulling and merging master to the feature branch? 如何检查master是否已合并到当前分支 - How do I check if master has been merged into current branch 如何安排从master分支到我的功能分支的合并,并在我的功能分支上提交自己的工作? - How shall I arrange merge from the master branch into my feature branch and commit of my own work on my feature branch? 我如何知道一个分支是否已经合并到 master 中? - How can I know if a branch has been already merged into master? 将其与本地主服务器合并后,是否应该删除LOCAL remote / origin / master分支? - Should I delete the LOCAL remote/origin/master branch after I have merged it with my local master? 我可以安全地删除已合并到master的Git主题分支吗? - Can I safely remove my Git topic branch that has been merged into master? Git:如何删除已经提交,推送并合并到master的分支? - Git: How do I remove a branch that has already been committed, pushed, and merged into master? 使用 Git,在我的代码提交合并到 master 分支后,我是否要删除我的远程分支,再次克隆 master 并检查下一个分支? - With Git, after my code commits are merged to the master branch, do I delete my remote branch, clone master again and checkout the next branch? 我如何处理已合并的远程分支的本地提交? - What do I do with local commits for a remote branch that has been merged?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM