I have a branch I want to delete but possibly be able to restore it with full history -is there a way to do this ? So want this:
a - b - c - d - e master
\
f - g tmp
to become:
a - b - c - d - e
and have a - b - f - g stored somehow that I can reapply it - is it possible ?
Perhaps you could use git fast-export to save the branch to a file. Then if you need it later you can use git fast-import to get it back.
To accomplish saving the single branch tmp (that is, commits f and g), you could use the triple dot syntax, as follows:
git fast-export master...tmp
Just clone the repository to another location and then delete the branch from the original repository. You will be able to examine it in the cone and if needed pull it back in from there.
A branch in a clone is basically nothing more than a branch that lives somewhere distinct from your current repository. You can always move the branch back to your old repository at a later point.
It's even easier to push back the branch to your original repository from your clone.
So, in your clone just do:
git push origin that_branch
Ever pushed a branch to github? Yep, that's exactly the same thing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With