Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using git-tfs fetch to get latest causes a merge conflict

Tags:

git-tfs

I have an issue attempting to pull my latest changes from TFS and adding them to a BitBucket repo. I have successfully pushed my branches into BitBucket, but when I attempt to get any new checkins from TFS I always get a merge conflict.

Steps:

  1. git tfs clone http://TFS-ADDRESS/Collection $/Project/Name/Branch
  2. git tfs init-branch $/Project/Name/NewBranch NewBranchName
  3. git push -u origin --all

At this point my BitBukcet repo has all my files and history from TFS. I then did a checking into me $/Project/Name/NewBranch on TFS.

Now I want to get the latest changesets from TFS and add/commit them into the BitBucket repository Note: At this point, no other branch in TFS or BitBucket has changed. The only change is my single check-in into TFS

When I do the following on my NewBranch, I get a merge conflict:

git tfs pull

Auto-merging Source/build.version
CONFLICT (content): Merge conflict in Source/build.version

As far as I can tell, it is trying to merge changes from my "master" to my "NewBranch", even though NewBranch is the latest code. The ptfs pull command is pulling the last checgeset down, but then tries to do the merge. If I use

git tfs fetch --all

I see the changeset listed, but I cannot commit/push it to the BitBucket repository. I cannot find a reference online to say what I am doing wrong, or what steps I need to take (I am new to Git). Can anyone help?

I eventually want to automate this so any check-ins in TFS can be fetched and added to the BitBucket repository (until we eventually move all developers to BitBucket)

Thanks

EDIT I am trying to take changes from TFS to BitBucket. Nothing is getting added to TFS from BitBucket.

All work is done on a branch (see below). Users are working in TFS. Users commit their changes there. NOTE: No-one is making edits to the BitBucket repo. It is a replica of TFS. Once a day, I want to pull the latest changesets for each TFS branch down to my local git folder and them push them into BitBucket. The "git tfs fetch" retrieves the changesets:

D:\development\workspaces\git\anothertry>git tfs fetch --all
C83419 = 3abdaedf571369dce15f74a52697d86069f87d6d

but "git status" tells me there is nothing to commit

D:\development\workspaces\git\anothertry>git status
# On branch Feature
nothing to commit, working directory clean

And when I try to push this changeset into BitBucket, git tells me there is nothing to commit.

Branches

Master---o---------------o----o--o-o--o-------
          \             /    /  / /  /
           Feature-----o----o--o-o--o
like image 371
Simply Ged Avatar asked Nov 03 '22 23:11

Simply Ged


1 Answers

I seem to have found the answer after using Git Extensions.

It seems I need to do a fetch

git tfs fetch --all

This will get me all changesets from TFS for my trunk and any branches I have mapped (init-branch)

D:\development\workspaces\git\anothertry>git tfs fetch --all
C83454 = f65ba8d0cc7b40f42148ba2c06d0da8b7e968c4d
C83455 = 6c25feb6e74a09d0d3d84344002e7546044900ab
C83459 = 91c4450d702d5a97e862aedd7ad1b5af3ff2c375
C83460 = 5cacaba5bfe4197c1bf9fab498f51c1ba435e6ea

Next I need to perform a merge

git merge <guid>

NOTE: The is for the latest changeset (in this case 5cacaba...)

Updating 6c25feb..5cacaba
Fast-forward
 Source/Common/w32threads.h             | 1238 ++---
 Source/xxxxxxx_Service/ServerAgent.cpp | 3638 ++++++-------
 Source/xxxxxxx_Service/ServerAgent.h   |  449 +-
 Source/xxxxxxx_Service/User.cpp        | 9073 ++++++++++++++++----------------
 Source/xxxxxxx_Service/User.h          |  647 +--
 Source/build.version                   |    2 +-
 6 files changed, 7562 insertions(+), 7485 deletions(-)

And, finally, push my changes to BitBucket

git push --all

So, it seems I was missing the git merge call and the parameters to pass to it.

Cheers

like image 120
Simply Ged Avatar answered Jan 04 '23 15:01

Simply Ged