[英]How to fix a bug in a branch after it has already been merged with master?
Below is my current process. 以下是我目前的流程。 The idea is stable master.
这个想法是稳定的主人。 We make our changes on our own branches and then merge with master.
我们在自己的分支机构上进行更改,然后与master合并。
Does this seem correct to you? 这对您来说是否正确? Is there a better flow?
有更好的流程吗?
Thank you. 谢谢。
Yes, You can fix your bugs in your branch . 是的,您可以在分支机构中修复您的错误。 Then add, commit, push and merge with master.
然后添加,提交,推送并与master合并。
$ git checkout <branch-name>
Fix bugs here
$ git commit -am 'Fix bugs' # add and commit
$ git push origin HEAD
$ git checkout master
$ git pull origin master
$ git pull origin <branch-name>
$ git push origin HEAD
You can do changes on your branch and merge them to master again, but as I can see you have already pushed both master and your branch to remote repository. 您可以在分支上进行更改,然后再次将其合并为master,但是正如我所见,您已经将master和分支都推送到了远程存储库中。 Remember that you should not amend commits already pushed to the remote, so you cannot use
git commit -a
! 请记住,您不应该修改已经推送到远程的提交,因此您不能使用
git commit -a
!
Maybe easier and cleanier way to do it would be to fix changes on your branch and then cherrypick just this one commit with fixes. 也许更简单,更干净的方法是修复分支上的更改,然后仅对这一提交进行修复。 It would look like this (assuming you are on master right now)
看起来像这样(假设您现在是主人)
$ git checkout <branch-name>
fix bugs
$ git commit -m "fixes"
$ git push origin <branch-name>
$ git log
from git log get the commit Id , it would look like this: 从git log获取提交ID ,它看起来像这样:
commit 4cc1c6ec2d5dc2ce21557681c9abddced1a56645
Author: your name <e-mail>
Date: Wed Nov 30 10:51:45 2016 +0100
commit message
Now copy commit ID and use it co move fixes to master 现在复制提交ID并将其用于共同修复
$ git checkout master
$ git cherry-pick 4cc1c6ec2d5dc2ce21557681c9abddced1a56645
$ git push origin master
This way you will have the same commit with fixes on both master and your branch. 这样,您将对master和您的分支进行相同的提交和修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.