I am learning GIT these days, moved from svn to git. Can anyone help me figure out which is the good practice in case below.
这些天我正在学习GIT,从svn转到git。任何人都可以帮我弄清楚哪种是下面的情况下的好习惯。
Suppose I am working on two issues. I have created 2 branches to work. branches: issue1 and issue2
假设我正在处理两个问题。我创建了2个分支来工作。分支:issue1和issue2
Approach 1
I can directly pull latest codes to my branch issue1 or push to origin master by commands
我可以直接将最新代码拉到我的分支问题1或通过命令推送到原始主代码
Currently on branch issue1 :
目前在分支机构问题1:
Pull from origin master git pull origin master
从原点主机git pull origin master拉出
Push to origin master git push origin issu1:master
推送到原始主机git push origin issu1:master
Approach 2
Merge branch issue1 after fixing in it and push to origin master.
在修复后合并分支问题1并推送到原始主文件。
Currently on branch master git merge issue1
then git push
(push to origin master)
目前在分支机构主机git merge issue1然后git push(推送到原始主机)
So I want to know If I go with approach 1 I will never need to merge with my local master and push. Which is the good way to go? What is the difference between this two approaches? Thank you in advance.
所以我想知道如果我采用方法1,我将永远不需要与我的本地主人合并并推动。哪个好方法去?这两种方法有什么区别?先感谢您。
2 个解决方案
#1
Once you have finished working on an issue, you no longer need the branch. Like @user3751845 said, Approach 1 is good for collaborating with a team. Otherwise, the new branch is unnecessary, so go with Approach 2.
完成某个问题后,就不再需要该分支了。就像@ user3751845所说,方法1很适合与团队合作。否则,新分支是不必要的,因此请使用方法2。
(first answer on Stack Overflow! woo!)
(Stack Overflow上的第一个答案!喔!)
#2
Approach 1 seems to be better when there are other team members, that should review a change in a branch and make the merge. Approach 2 is better in other cases.
当有其他团队成员时,方法1似乎更好,应该检查分支中的更改并进行合并。方法2在其他情况下更好。
There are many branching models out there. See https://www.atlassian.com/git/tutorials/comparing-workflows/
那里有许多分支模型。请参阅https://www.atlassian.com/git/tutorials/comparing-workflows/
PS: As @choroba already mentioned it seems to be a bad advise to push from a local feature branch to the remote master.
PS:正如@choroba已经提到的那样,从本地功能分支推送到远程主机似乎是一个糟糕的建议。
#1
Once you have finished working on an issue, you no longer need the branch. Like @user3751845 said, Approach 1 is good for collaborating with a team. Otherwise, the new branch is unnecessary, so go with Approach 2.
完成某个问题后,就不再需要该分支了。就像@ user3751845所说,方法1很适合与团队合作。否则,新分支是不必要的,因此请使用方法2。
(first answer on Stack Overflow! woo!)
(Stack Overflow上的第一个答案!喔!)
#2
Approach 1 seems to be better when there are other team members, that should review a change in a branch and make the merge. Approach 2 is better in other cases.
当有其他团队成员时,方法1似乎更好,应该检查分支中的更改并进行合并。方法2在其他情况下更好。
There are many branching models out there. See https://www.atlassian.com/git/tutorials/comparing-workflows/
那里有许多分支模型。请参阅https://www.atlassian.com/git/tutorials/comparing-workflows/
PS: As @choroba already mentioned it seems to be a bad advise to push from a local feature branch to the remote master.
PS:正如@choroba已经提到的那样,从本地功能分支推送到远程主机似乎是一个糟糕的建议。