Git branch vs Git fork

被刻印的时光 ゝ 提交于 2021-01-27 22:00:21

问题


I have a general doubt. Suppose there is a git repo with master branch as development branch and you want to make some changes without effecting master branch and then you want to merge it later. What is the better approach?

  1. Create new branch in same repo and then merge it to master.
  2. Create new repo by forking and then merge it to master.

回答1:


If you know for sure that you will end up merging with the master branch eventually and/or your change is relatively small (bug fixes, new features), then definitely make a new branch. Only make a fork if you are going to make vast changes that could potentially become a new project in itself. That's the rule of thumb that I follow (as it follows the basic project design meta of git), so I hope that helps.




回答2:


I would strongly suggest to create a new branch in the same repository. You do your work in this new branch until the new feature is complete. When it's finally complete, merge it back into master. This follows the design of git.

There really is no forking in it. There are only clones of the original. The more clones you create, the more complicated things become and the more work you have to do with pull requests to get the changes back into the original repository.




回答3:


I would suggest the below strategic.

  1. Master -->Production deployed one and source of all:

  2. develop -->Always in-sync with Master

    • feature/Branch.
      • Multiple developer branches with base of feature/Branch.
        • Raise PR to feature/Branch.
      • Once done a feature developments & testing on the feature/Branch, create PR to develop branch for UAT/SIT testings.
    • BugFix/Branch.
  3. develop/Fork-->This branch should always in-sync with develop. You can enable this by mark the "Enable force sync" on Bitbucket Server.

    • production bugfix/Branch.
      • Once bug fix was done Raise PR to develop/Fork branch.
      • deploy develop/Fork branch into UAT/SIT.
      • Then raise PR to develop to merge bugfix changes.



回答4:


Forks can be a really good pattern for ‘public’ collaboration and experimentation, but when the intended use case is many people working toward a unified goal, branching tends to be a better fit

Hence

Choose option #1 - if you are working together in a team and developing software.

Choose option #2 - if you are going to contribute to any open-source projects.



来源:https://stackoverflow.com/questions/38110090/git-branch-vs-git-fork

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!