Thursday, January 16, 2014

Avoiding merge conflicts with git tf

Recently I began using git tf to interface with a Microsoft TFS repository for a client.  I quickly began to encounter problems when trying to merge TFS changesets into my local repository when issuing the git tf pull --rebase command.  Sometimes the issues would be simple conflicts, but other times I would encounter bizarre problems that I could not easily resolve.

My solution was to adopt a modified workflow using a local branch, e.g., “Working”.  I perform all of my code changes on the Working branch and use master only for TFS interactions.  Here is a typical workflow:

  1. Start my day
  2. git checkout master
  3. git tf pull --rebase
  4. git checkout Working
  5. git merge master -m “Merged latest changes from TFS.”
  6. Make changes to the code in my local git repository
  7. git commit -a -m “commit local into Working branch”
  8. Merge my local Working changes into master
  9. git checkout master
  10. git tf pull --rebase
  11. git merge Working --no-commit
  12. Fix any merge conflicts and then check updated code in to TFS
  13. git tf checkin
  14. git checkout Working
  15. Resume local code changes

I have not had any more bizarre, unsolvable problems since adopting this new workflow.

2 comments:

  1. DUDE: thank you! This has become an integral part of escaping Parallels/VS ;)

    ReplyDelete