Git to TFS Migration Experiment: Part 3

July 20, 2014

Git: Learning, Nerd, TFS

 3: Pushing to TFS

> git tf checkin –deep –autosquash

Hooray! Success… I think!

There were quite a few things I learned getting to that point:


3a. Troubleshooting “git-tf: Could not lock” error:

PreReq Step 5, on post 1 (creating your project in TFS), was missed.


3b. Troubleshooting “git-tf: ‘refs/heads/master’ is not a valid ref” error:

Your repository does not have a local branch named “master”


Git-TF does not support TFS Branches (git-tfs does).

p.s.”>git tf checkin” only checks in your master branch (git tf bridge limitation)

“Fun” Fact (elaborating on Git-TF Gotcha):

The libgit2sharp repo has the “vNext” branch set as the default:


Although this repo HAS a master branch, when you clone it, only the vNext local branch is created by default:



…how do I get around this?

Remember: In this case, our initial clone did *not* create a local branch named “master” because vNext was set as its default in the remote repo. THIS IS NOT COMMON but it’s good to be aware of.


>git checkout master

Note what happens: Because the libgit2sharp repo *has* a branch named, “master,”, this creates a local branch named, “master” as a tracking branch to origin/master, and switches to that branch by updating the files in your working directory to match the snapshot origin/master points to (which was already fetched when repo was cloned):


You can see that both branch heads now exist:
If you open each of those in a text editor, you’ll see they point to different commits. Another fun trick to see commit pointer info is to type:

>gitk –branches –simplify-by-decoration
>git branch -a -v

You can see master points to the same sha1 as origin/master (05e6633), and vNext points to the same sha1 as origin/vNext (91456eb).


3c. Troubleshootinggit-tf: cannot check in – commit [sha1] has multiple parents, please rebase to form a linear history or use –shallow or –autosquash” error:


Git-TF is nice enough to tell you there are 3 ways to workaround this:

  1. –autosquash
  2. git rebase –i
  3. shallow clone

After using gitk to investigate the commit responsible for the error, I realize this goes back to the fundamental differences between how git & tfs work.


Commit 090b2de was a merge commit that combined separate work from 2 snapshots. A TFS branch can only have a linear history, so you must tell GIT-TF how to handle these, if you want to transfer the “deep” history (shallow will give you only the latest “snapshot” with no history).


3d. Troubleshootinggit-tf: cannot perform the initial check in against a non-empty folder. Destination needs to be empty, please configure your repository against another tfs folder” error:

Your project folder is not empty. See 2b – Note, in Part 2. You can re-run git tf configure to update the value.

image_thumb13[1]In the next part in the series, I’ll



  1. Git to TFS Migration Experiment: Conclusion | Truncated CoDr's Blog - August 28, 2014

    […] Part 3 […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: