问题
I've to transfert a TFS server to a GIT(Bitbucket) server.
We are currently using git-tfs
to do it, but we are doing some tests before migrating(like configuring jenkins, checkin that everything is correctly transfered).
The issue is that now it seems I cannot run the git push
command because I've the repository that is already filled with a lot of stuff from the previous run.
Is there a way to "reset" the repository(like if I've never done any commit) ? Without deleting it?
I've found this: Clear git repository on Bitbucket? but the issue is that I'm committing 6 years of work, with more than 60 branches, so I cannot just clean them one by one.
I also cannot just delete the repository, we have already configured a lot of things(hooks, connections to jenkins, ...).
回答1:
This really depends on the TFS version/bitbucket. You could just delete all the branches and tags and reset Master to the very first commit to get a clean slate. But depending on your TFS server version this may actually not cause the "garbage" to be collected. I;m not sure about the garbage collection policies on BitBucket.
Git garbage collection was introduced in TFS 2015 update 3 and older versions won't actually clean up anything on the server, even if you've deleted all references to it.
You could easily script the cleanup process. use git fetch --all
to make sure your local repo has all branch information, then use git branch --list -r
to list all remote branches. With that you can easily script deleting these branches and pushing their deletion to the server.
Then use git update-ref refs/heads/master a12d48e2 (insert your own commitish) to reset the master.
Then git push --force --all
to send everything back to the server.
来源:https://stackoverflow.com/questions/41564981/clear-git-repository