Skip to content

Repository cleaning

bjorng edited this page Sep 13, 2010 · 7 revisions

Topic branches are in general not useful after a release. When I make the release, I rebase all
topic branches before merging them, so that the history will get linear. I want to have an editing
history that is easy to read five years from now, when I’ll have to find out why a particular
change was made or to find out when a particular feature was introduced.

Therefore, after a release you should remove the topics branches that have been included in
the release, both locally and in your Github repository.

The reason that I care about this is that I see all of your published branches as remote branches
in my repository and I might include the wrong branch in a release or forget a branch in a release.
Therefore I would be very grateful if you remove all old branches after every release.

Also, it would help me if you don’t publish the ‘pu’ branch to your Github repositories. It will also
end up in my repository, and as I watch your repositories I will also see it as a change (and I might
miss other changes that should be included in the release).

Deleting branches at Github

To delete a branch that has been published to Github:

git push origin :branch-name

Several branches can be deleted at once:

git push origin :branch-name1 :branch-name2 :branch-name3

To avoid having to type the name of all branches, the following script

git-clean-stale-branches

can be used to remove all branches that don’t exist in your local repository from
your Github repository. The script prints the command git command needed to
remove the branches. To actually remove the branches, either copy and paste
the command, or pipe its output to sh like this:

git-clean-stale-branches | sh

Cleaning out other’s remote branches

If you have fetched from my Github repository, remote branches will remain even if I have
subsequently removed them. To get rid of all such stale branches do:

git remote prune bjorng