[git] Mess with branches

What's the current policy about merging and removing branches in libraries? Can I for example merge and remove old svn-branches/filesystemv3 in module boost/conversion or will it break some functionality? -- Best regards, Antony Polukhin

2013/12/3 Antony Polukhin
What's the current policy about merging and removing branches in libraries? Can I for example merge and remove old svn-branches/filesystemv3 in module boost/conversion or will it break some functionality?
Hi Antony, The boost superproject references the branches 'master' and 'develop' plus the tags. Apart from these, you are free to remove branches. Cheers, Daniel

2013/12/3 Daniel Pfeifer
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 -- Best regards, Antony Polukhin

Date: Wed, 4 Dec 2013 17:48:06 +0400 From: antoshkka@gmail.com To: boost@lists.boost.org Subject: Re: [boost] [git] Mess with branches
2013/12/3 Daniel Pfeifer
<...> 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.

Ahmed Charles
Date: Wed, 4 Dec 2013 17:48:06 +0400 From: antoshkka@gmail.com To: boost@lists.boost.org Subject: Re: [boost] [git] Mess with branches
2013/12/3 Daniel Pfeifer
<...> 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.
+1 It's easy to make a ref like branches/hidden/xxx that doesn't show up unless you really, really try to find it.
participants (4)
-
Ahmed Charles
-
Antony Polukhin
-
Daniel Pfeifer
-
Dave Abrahams