Boost logo

Boost :

Subject: Re: [boost] [git] Mess with branches
From: Ahmed Charles (acharles_at_[hidden])
Date: 2013-12-07 01:06:32


> Date: Wed, 4 Dec 2013 17:48:06 +0400
> From: antoshkka_at_[hidden]
> To: boost_at_[hidden]
> Subject: Re: [boost] [git] Mess with branches
>
> 2013/12/3 Daniel Pfeifer <daniel_at_[hidden]>
> <...>
>
> > The boost superproject references the branches 'master' and 'develop'
> > plus the tags.
> > Apart from these, you are free to remove branches.
> >
>
> Just in case someone will be interested in how to remove branches with an
> ability to restore the branch and without making a tag from it, here's my
> recipe:
>
> 1. Checkout Boost from git:
> https://svn.boost.org/trac/boost/wiki/TryModBoost
> 2. cd libs/your_library_name
> 3. git checkout develop
> 4. git pull
> 5. git branch -r >../../branches.txt
> 6. remove from ../../branches.txt following branches "origin/HEAD ->
> origin/master", "origin/develop", "origin/master" and branches that you do
> with to save (for example "origin/svn-branches/maintenance/1_55_0")
> 7. git merge --no-commit list_of_branches_from../../branches.txt
> 7.1 in case of conflicts revert merge using git merge --abort
> 7.2 if you are sure that there is nothing good in branches but they must
> be restorable "just in case" do "git merge -s ours --no-commit
> list_of_branches_from../../branches.txt"
> 8. validate that everything is OK using git diff HEAD
> 9. git commit
> 10. git push
> 11. git push origin --delete
> list_of_branches_from../../branches.txt_but_with_removed"origin/"
>
> In short:
> 1. git merge -s ours --no-commit branch_name
> 2. git push origin --delete branch_name
>
> This will make it look like branches were merged to "develop" branch
> without actually making any changes to files. (commits that are reachable
> from a tag or a non-deleted branch head won't be lost).
>
> Now if you really need to restore a branch you could find that huge merge
> commit in history, find SHA of branch that you wish to restore and do:
>
> git checkout -b branch-name SHA

I think this is a bad idea since it makes the history look like those changes were merged as opposed to a branch that still has unmerged code on it. I'd probably recommend pushing it to a ref that is hidden and therefore, only exists in github.
                                               


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk