-1

我们一直在团队中反复讨论个人开发人员使用功能分支、变基等的最佳流程。以下是我们提出的(来自一些邮件列表的输入),但似乎有点复杂的&有很多步骤。还有其他一些带有一些答案示例的 SO 问题看起来相似且更简单。

这是一个好的工作流程吗?如何简化(如果有的话)或改变?

git checkout develop # all developer work is off of this branch
git pull --rebase # make sure local develop is up-to-date
git checkout -b my-nifty-feature-559876 # create your feature branch; I like to put Pivotal story ID in it for convenience; not required

# do your work, make sure all tests still pass, etc. COMMIT FREQUENTLY
git commit -m "First part of my nifty feature working; now on to the back-end."

# fetch latest remote develop and rebase your local feature branch on this.
git fetch
git rebase origin/develop
# Local feature branch now has latest origin/develop code as base

# repeat above 3 frequently as you're working

# when you're done, pull and rebase one last time, make sure tests pass, then final commit with Pivotal comment
git commit -m "It works! [Fixes #559876]" # commit when done. Include comment like that for Pivotal integration
git fetch
git rebase origin/develop

# Local feature branch now has latest origin/develop code as base

git checkout develop # switch back to develop
git pull
git merge my-nifty-feature-559876 # This should be a simple FF merge
git push origin develop # send to github
git branch -d my-nifty-feature-559876 # you can get rid of your feature branch
4

1 回答 1

-1

这几乎就是git 的工作流程。几乎所有其他 VCS 都一样。

git rebase origin/developvs.git merge origin/develop是一个口味问题,但两者在最终结果上基本相同。Rebase 提供了更清晰的历史记录,但合并意味着您始终可以回滚到昨天的位置。

同样,有时我更喜欢进行最终合并--squash以保持主分支历史更加清晰。

一个我认为非可选的小技巧:在变基之前备份。如果你使用 rebase 来重写历史,你就有可能毁掉一切,然后无法回滚。

git branch my-nifty-feature-559876-BACKUP
git rebase origin/develop

# verify everything rebased ok
git branch -D my-nifty-feature-559876-BACKUP

创建新分支意味着您在变基之前拥有功能分支的副本。如果变基出现严重错误,您可以使用reset回滚。

于 2013-08-27T13:52:55.803 回答