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!

image_thumb1
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.
image_thumb6_thumb

 

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

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

Git-TF GOTCHA:

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:

image18_thumb

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

image27_thumb

image20_thumb

…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.

image37_thumb

WORKAROUND:
>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):

image_thumb13

You can see that both branch heads now exist:
image_thumb14
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
or
>git branch -a -v

image_thumb10
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:

image_thumb2

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.

image_thumb3

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

image_thumb4

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

 

Trackbacks/Pingbacks

  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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: