I've been working on big repo for years now.
This is a strategy that works. I'm not saying it's the best one but it works and scale.
How to keep repository clean?
Everybody fork the main repo and no commit / branch creation is allowed on the main repo.
Dev create a branch on his own repo, then he create a pull request on main repo.
Delete local branches and keep the remotes?
In GitLab/ GitHub, you have an option to delete the branch when PR is merged.
Then from time to time you can run git fetch -p to clean up your local repo. On you repository, there's usually a button to remove merged branches. You can also manually remove old branches (i.e. latest commit > 60 days).
Delete remote branches and lose the Jira link on historical tickets?
For this, I couldn't agree more with @cescquintero
. You can link the ticket number to the commit message ;)
Hey,
good question!
I've been working on big repo for years now.
This is a strategy that works. I'm not saying it's the best one but it works and scale.
Everybody fork the main repo and no commit / branch creation is allowed on the main repo.
Dev create a branch on his own repo, then he create a pull request on main repo.
In GitLab/ GitHub, you have an option to delete the branch when PR is merged.
Then from time to time you can run
git fetch -p
to clean up your local repo. On you repository, there's usually a button to remove merged branches. You can also manually remove old branches (i.e. latest commit > 60 days).For this, I couldn't agree more with @cescquintero . You can link the ticket number to the commit message ;)
Thanks for sharing!! This is exactly what I needed.
--prune
After fetching, remove any remote tracking branches which no longer exist on the remote.