Should we remove a remote Git branch after merging to master?

时光怂恿深爱的人放手 提交于 2019-12-05 13:12:56

So there are tons of literature about how to manage your branches but really I think it comes down to how you want to manage things within your own project. That being said, here is a link for branch workflow from Atlassian that could give a decent opinion:

https://www.atlassian.com/git/tutorials/comparing-workflows/feature-branch-workflow

Now, all that long article being said, if it makes sense for you all to commit straight to master, I don't think there is anything wrong with that. I personally commit to master for a couple small projects I work on but generally, this is the flow I follow:

  1. Create the master branch for the project
  2. Decide on a feature you want to work on, we'll call it Widget X.
  3. Create a feature branch for that, call it feature-widget-x.
  4. All the developers working on this feature should make their own branches based on what they are working on. For example, if I was working on error handling, I would branch off of feature-widget-x and make a branch called michael-error-handling.
  5. Merge everything into the feature branch and branch off from there as needed to complete the feature.
  6. When the feature is done, merge the feature branch back into the master branch.
  7. Tag and archive the feature branch so you can roll back if needed at any point.
  8. Clean up local developer branches.
  9. Create a new feature branch from master for Widget Y.
  10. Start the whole process again.

I want to note that this is strictly how I do things and has been successful for me in companies where it has been implemented. It may or may not be the best solution for your group of three members though but that is for you to decide. If you do go with this plan, it has the benefit of being able to roll back to a feature as needed and the only branches that persist are the feature branches and the master branch. Much easier than looking through commit logs on a single branch to figure out when you should roll back to if a commit breaks something.

Hopefully this helps. Here are a couple more links below for extra reading:

https://git-scm.com/docs/git-archive

https://git-scm.com/book/en/v2/Git-Basics-Tagging

How can I archive git branches?

The correct answer to your question is: it depends what you want to do. There is no problem with continue working on the branch that you merged with master. You can also simply delete it if you don't need it ! However, in the setting you describe, I totally agree with the fact that if you work on different parts of the project, then it may be safe to create different branches and keep the master branch as clean and updated as possible for the group.

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