Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve discrepancies found by Git-TFS verify

Git-TFS has a verify command, which the help describes thus: "The verify command helps identify inaccuracies of a fetch, clone or quick-clone from TFS." I have a proprietary repository which I am migrating from TFS to Git. Running git tfs verify revealed that there are a significant number of files missing from my Git repo that exist in TFS, and this right after doing a sync. This happened once before and I blasted the whole repository and started again, but now I've had the same problem again. I have cloned this repository successfully with Git-TFS before (before we began to migrate to Git, when I was just using it locally) so I know it can succeed, but I'd rather not blast the whole repository and start over again.

Is there an automatic way to patch up the differences shown by the verify command without re-cloning the whole repo? I could check out the project in TFS and copy all the files over manually if necessary but I am hoping for a better way.

like image 266
Keith Pinson Avatar asked Oct 31 '22 09:10

Keith Pinson


1 Answers

I was hoping for some sort of command like git tfs repair to correspond to the verify command. However, in lieu of finding something like that, I was able to solve this problem in two different ways. I had two repositories that were messed up, and one of them I had another copy of which was good (I had cloned it successfully for my own private use of Git before the department started to migrate from TFS to Git). The other I did not have a pre-existing copy, and every time I attempt to clone it I get the same problems.

The two solutions before worked to patch up the current state of the repo but of course did not tell the truth about the history. It would still be nice if there were any possible way to do something along the lines of git tfs repair.

When you already have another repo without discrepancies

I added my good repo as a remote to the repo I was trying to patch up:

git remote add goodclone C:/path/to/good/clone

Then I fetched from that remote:

git fetch goodclone

Git issued a warning that none of the commits were the same (this is a function of them having been cloned from TFS through Git-TFS at separate times). I knew this was true so that's okay. It just meant the clone took a while longer.

I checked out a branch from master to do the work on.

git checkout -b repair

I also checked out a branch from the good repo's remote, for good measure:

git checkout -b goodclone-master goodclone/master

I then merged:

git checkout repair
git merge --squash goodclone-master

I had to patch a couple things up, then I committed. I ran the TFS-Git sync process again, switched to master and pulled down the latest changes, rebased the repair branched on master, merged it into master, and pushed.

As far as I can tell, things are good now!

When you do not have another repo without discrepancies

I cloned the repository through TFS and then used Vim to create a script from the output of the verify command to copy the files over from the TFS repo. In the script I had to do mkdir -p for the contains directories before copying the files. I then committed the files to patch things up. It seems to have worked but is something of a hack.

like image 53
Keith Pinson Avatar answered Nov 09 '22 12:11

Keith Pinson