问题
I am using git-flow and many topic-branches, AKA feature branches. I was working on a feature branch, when it was decided to take an entirely different route.
I now want to remove that branch, as the work in there will not be merged into development or master and it only "clutters" the list of branches.
But I'd like to keep the history in that branch for historical and administrative purposes (and the odd chance that we all change our mind again and the archived work has to be dug out).
What would be the best route? Can I simply git branch -D
it and rise its death at a later moment? If so, what would be the command to do so?
回答1:
You could have a "graveyard" respoitory, separate from your working one, that just has archived branches in it? Then you can simply have it connected as a remote repository, push the archived branch to it and delete it from your local. It will still be there as remotes/graveyard/feature
回答2:
Use tags for that purpose. They won't clutter your branch listing.
回答3:
If you delete a branch, there is no going back. You have to make a decision whether to delete or not. Probably you can do something like:
git branch -m branch1 archive/branch1
Still pollutes your branch output, but you can filter it out.
回答4:
Had the same idea for somekind of archive repo.
My solution for it was to initiate a second server repo as archive repo, which is checked out as on the branch archive.
The main server repo is bare for a better usability when pushing and pulling from the client repos.
Only Issue that is still open is the one that the main repo and the clients are storing the archived objects too. I haven't found a solution for that, cause couldn't find the right combination of commands.
By the way is there a option for delaclaring some routine commands for clean-up and backups?
来源:https://stackoverflow.com/questions/8418635/delete-topic-branch-archive-for-administrative-purposes