问题:
A new branch from master is created, we call it test . 从master创建了一个新分支,我们称之为test 。
There are several developers who either commit to master or create other branches and later merge into master . 有几个开发人员要么致力于master要么创建其他分支,然后合并成master 。
Let's say work on test is taking several days and you want to continuously keep test updated with commits inside master . 假设test工作需要花费几天的时间,并且您希望通过master内的提交来不断更新test 。
I would do git pull origin master from test . 我会做git pull origin master从test 。
Question 1: Is this the right approach? 问题1:这是正确的方法吗? Other developers could have easily worked on same files as I have worked btw. 其他开发人员可以像我一样轻松地处理相同的文件。
My work on test is done and I am ready to merge it back to master . 我的test工作已经完成,我准备将其合并回master 。 Here are the two ways I can think of: 这是我可以想到的两种方法:
A: A:
git checkout test
git pull origin master
git push origin test
git checkout master
git pull origin test
B: B:
git checkout test
git pull origin master
git checkout master
git merge test
I am not using --rebase because from my understanding, rebase will get the changes from master and stack mine on top of that hence it could overwrite changes other people made. 我不使用--rebase因为据我所知,rebase将获得master的更改并在此基础上堆叠我的更改,因此它可能会覆盖其他人所做的更改。
Question 2: Which one of these two methods is right? 问题2:这两种方法中哪一种是正确的? What is the difference there? 有什么区别?
The goal in all of this is to keep my test branch updated with the things happening in master and later I could merge them back into master hoping to keep the timeline as linear as possible. 所有这一切的目的是使我的test分支随时master发生的事情,然后我可以将它们合并回master以期使时间轴尽可能保持线性。
解决方案:
参考一: https://stackoom.com/question/NVJj/将Git分支合并到master中的最佳-最安全-方法是什么参考二: https://oldbug.net/q/NVJj/What-is-the-best-and-safest-way-to-merge-a-Git-branch-into-master
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/4467364