0

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, ...).

Community
  • 1
  • 1
J4N
  • 19,480
  • 39
  • 187
  • 340
  • *... with more than 60 branches, so I cannot just clean them one by one.* What's the problem with scripting it? – Leon Jan 10 '17 at 09:30
  • @Leon I'm open to suggestion, but maybe a previous import didn't work properly or maybe it leaves some things that are not clear(not garbage collected) ? – J4N Jan 10 '17 at 09:32

1 Answers1

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.

Community
  • 1
  • 1
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • Hi, not sure why TFS version is important, but currently it's the TFS 2015. The issue I've with doing a `git --fetch --all`: It will change the git repository I just finished to generate after 8 longs hours, no? How to remove only the remote branch and not the local one? – J4N Jan 10 '17 at 10:24