The purpose is to destroy a remote. Say you are moving remote. You add the second remote to your local. Then push all refs to your new remote. After that, how do I clean my first remote of everything? As I am paranoid, I don't trust deleting the project will clear my data.
1 Answer
This is how I have done it.
First add your new remote
git remote add gitlab gl:user/prj
Then push all your refs
git push --all --tags gitlab
Then remove your new remote so you don't destroy that one.
git remote remove gitlab
Then clear all remote branches
git branch -a | grep -o remotes/.* | cut -c 9- | awk -F / '{st = index($0,"/");print "git push " $1 " :" substr($0,st+1) }' | bash
have fun
PS: don't do this before leaving your job.
Update: To answer @matt's comment
Commits data will get garbage collected in 30 days or depending on repo settings. While the commits are still present in the meantime and another develop can push all the branches references back. This effectively delete all branch references.
My mission is accomplished
-
2The problem is that you didn’t actually destroy any information. You didn’t “clear your data” at all. It’s all still there. So what’s the point. Your mission was not accomplished.– mattFeb 19, 2021 at 6:06
-
I appreciate you took the time to read and reply to my Q&A, thank you, @matt. I have updated my answer. Hopefully this clarifies it. Feb 20, 2021 at 6:05