1

I successfully cloned a TFS repository, but git log still shows HEAD pointing to both master and tfs/default as follows:

(HEAD -> master, tfs/default)

I already tried the filter-branch command, as well as remove the [tfs], [git-tfs] sections from configfile and run the following commands:

git reflog expire --all
git gc --aggressive --prune
git tfs cleanup
git tfs cleanup-workspace

But it's still there. The only thing that works is deleting the .git folder then running git init but of course this loses all history. I also checked git config --list --show-all but there is no remote TFS repository in there.

Question
Is it possible to completely disconnect TFS from the git repo without losing history after using git-tfs and if yes, how?


EDIT
The accepted answer works and is instructive but see this answer on SuperUser for what I understand is a 'safer' way to do this.

evilmandarine
  • 4,241
  • 4
  • 17
  • 40

1 Answers1

2

Is it possible to completely disconnect TFS from the git repo without losing history after using git-tfs

Your git repo is not "connected" to the TFS server. It just contains some data the allow git-tfs to be able to interact with the TFVC source control.

What you see tfs/default is a pseudo git remote branch to keep track of the last changeset retrieved.

and if yes, how?

As it is stored as a git remote, the easier is to delete the file:

.git/refs/remotes/tfs/default

Note: if you can't find this file, this is because there is a possibility that the ref is packed in the file .git/packed-refs. If there, delete the line corresponding to refs/remotes/tfs/default

Philippe
  • 28,207
  • 6
  • 54
  • 78
  • It's in packed refs, but there are 5 lines in there: `refs/heads/master, refs/notes/commits, refs/original/refs/heads/master, refs/original/refs/remotes/tfs/default, refs/remotes/tfs/default`. Could you please specify in the answer which one(s) I should remove without breaking something? – evilmandarine Mar 11 '21 at 23:18
  • @evilmandarine The answer to your question is already in my previous answer. You should remove `refs/remotes/tfs/default`. The others `refs/original/*` were created when you did a 'filter-branch' or something similar and could in all probability deleted also. But it is easy to test for you. Backup the file and remove the parts to try. See the effect and if it suits you, that's OK otherwise undo the changes. That's how we learn all... – Philippe Mar 12 '21 at 00:05
  • @evilmandarine see my previous comment (I forgot to mention you so you probably didn't get the notification) – Philippe Mar 12 '21 at 00:07
  • Your answer works, thank you. I just like to understand what I am doing instead of just trying and seeing if it works. Looking for what are packed refs I found [this answer on SuperUser](https://superuser.com/a/351085/570990) and ended up doing `git show-ref default`, then `git update-ref -d refs/original/refs/remotes/tfs/default` and `git update-ref -d refs/remotes/tfs/default`. – evilmandarine Mar 12 '21 at 09:14