Craig E. Shea 334a040e98 Improve branch point changeset detection
@jeremy-sylvis-tmg is the original author of this commit. He originally
issued Pull Request #973. However, a code review was performed by myself
and @pmiossec whereby changes were requested. Unfortunately, the author of
the pull request declined to make the requested changes due to time
constraints.

Because the changes implemented in this commit could potentially solve a
long outstanding problem in how git-tfs currently detects branch point
changeset detection, I have recreated this commit with the requested
changes.

Basically, this commit allows gits-tfs to properly clone a TFS branch into
a git repository when the branch was first created as a folder, deleted,
and subsequently created as an actual TFS branch:

   *--C1--C2--C3--C4(X)--*--*--*
	            \
		     C5(?)--*--*

In the diagram above, a folder would be created at C3 called 'Branch'. At
C4, it was determined that either C3 was a mistake, or simply that a true
TFS branch was desired as opposed to a TFS folder. So at C4, the folder
named 'Branch' is deleted. At C5, an actual TFS branch called 'Branch' is
created, and C5 is the first changeset on TFS branch 'Branch'.

Prior to this commit, Git-Tfs would get "confused" because branches and
folder in TFS are similar, but not the same--and there's no analogue in
Git whatsoever. The branch 'Branch' usually fails to clone properly, and
IIRC, you'll get messages such as "Could not find parent changeset for
branch 'Branch'". In my experience, providing a parent changeset ID does
not always resolve the situation satisfactorily.

The changes in this commit detect this situation. At C3, it detects that a
folder was created, called 'Branch'. TFS folders are not branches, and so
this commit causes git-tfs to keep searching through TFS history for the
most recent branch point. So, when the folder named 'Branch' is deleted at
C4, git-tfs will continue to search for merge history, which it finds at
C5, where the TFS branch named 'Branch' is created. This is a true branch
point off of the main line. Because C3 and C4 effectively "cancel" each
other out, the resulting Git history after cloning this TFS repository
history looks like the following (NOTE: this author is unsure how git-tfs
represents commits C3 and C4 in the commit history of a Git repository
since Git has no concept of "folders"):

    *--C1--C2--C3--C4(X)--*--*
            \
	     C5--*--*

NOTE: This commit does add some methods to an interface. As such, the next
version of Git-TFS should have it's minor version incremented; e.g. the
next version of Git-Tfs released containing this commit should be in the
0.26.x series.

Signed-off-by: Craig E. Shea <craig.e.shea@gmail.com>
2016-11-12 20:46:14 -05:00
2016-10-31 15:46:01 +01:00
2015-04-21 21:39:18 +02:00
2014-02-11 11:57:55 -05:00
2016-03-02 16:46:15 +02:00
2015-04-21 21:39:18 +02:00
2013-11-17 02:02:45 +01:00
2009-10-26 12:22:43 -04:00
2016-10-22 01:16:59 +02:00
2015-07-18 23:54:51 +02:00
2010-02-12 09:25:18 -05:00
2012-01-30 08:21:20 -05:00
2012-11-14 07:56:31 -05:00
2016-10-31 15:46:01 +01:00
2015-08-05 17:54:46 +02:00
2016-10-18 22:10:22 +02:00

Introduction

git-tfs is a two-way bridge between TFS (Team Foundation Server) and git, similar to git-svn. It fetches TFS commits into a git repository, and lets you push your updates back to TFS.

git-tfs version. See the change history for details and download.

If you're having problems, check out the troubleshooting page. And read how to report an issue, before doing so ;)

Get git-tfs

To get a stable version:

To get a development version

  • Build from source code. See §Building for more informations...
  • Download a package of the development version generated by the last builds (in the artifacts section).

Whatever the way you get git-tfs, you should have git-tfs.exe in your path (and git, too).

Add the git-tfs folder path to your PATH. You could also set it temporary (the time of your current terminal session) using :

set PATH=%PATH%;%cd%\GitTfs\bin\Debug

Use git-tfs

You need .NET 4 and either the 2010, 2012 or 2013 version of Team Explorer installed (or Visual Studio).

Help

#lists the available commands
git tfs help

#shows a summary of the usage of a given command
git tfs help <command>

Cloning

# [optional] find a tfs repository path to clone :
git tfs list-remote-branches http://tfs:8080/tfs/DefaultCollection

# clone the whole repository (wait for a while...) :
git tfs clone http://tfs:8080/tfs/DefaultCollection $/some_project

# or, if you're impatient (and want to work from the last changeset) :
git tfs quick-clone http://tfs:8080/tfs/DefaultCollection $/some_project

# or, if you're impatient (and want a specific changeset) :
git tfs quick-clone http://tfs:8080/tfs/DefaultCollection $/some_project -c=145

Note: Before cloning your repository, please have a look at the clone command doc or advanced use cases to discover options that could help you!

Working

cd some_project
git log # shows your TFS history, unless you did quick-clone
tf history # error: no workspace ;)

# [do work, do work, just using git], then...
# gets latest from TFS to the branch tfs/default :
git tfs fetch

Checkin

# report all the commits on TFS :
git tfs rcheckin

# or commit using the tfs checkin window
git tfs checkintool

# or commit with a message
git tfs checkin -m "Did stuff"

# or shelve your changes :
git tfs shelve MY_AWESOME_CHANGES

git-tfs is designed to work outside of any existing TFS workspaces.

More advanced use cases

Have a look to more detailed git-tfs use cases:

Available commands / options

This is the complete list of commands in the master branch on github.

Repository setup

  • list-remote-branches: list tfs branches that can be cloned or initialized - since 0.17
  • clone: clone a tfs path/branch and its history in a git repository - since 0.9
  • quick-clone: clone a specific changeset of a tfs path/branch in a git repository - since 0.9
  • bootstrap: bootstrap an existing git-tfs repository cloned from an existing repository - since 0.11
  • init: initialize a git-tfs repository (without getting changesets) - since 0.9

Pull from TFS

  • clone: clone a tfs path/branch and its history in a git repository - since 0.9
  • fetch: get changesets from tfs and update the tfs remote - since 0.9
  • pull: get changesets from tfs, update the tfs remote and update your work - since 0.9
  • quick-clone: clone a specific changeset (without history) of a tfs path/branch in a git repository - since 0.9
  • unshelve: fetch a tfs shelvesets in your repository - since 0.11
  • shelve-list: list tfs shelvesets - since 0.12
  • labels: fetch tfs labels - since 0.17

Push to TFS

  • rcheckin: replicate your git commits as tfs changesets - since 0.12
  • checkin: checkin your git commits as one tfs changeset - since 0.10
  • checkintool: checkin in tfs using the tfs checkin dialog - since 0.10
  • shelve: create a shelveset from git commits - since 0.9

Manage TFS branches

Other

  • info: get some informations about git-tfs and tfs

  • cleanup: clean some git-tfs internal objects - since 0.10

  • cleanup-workspaces: clean tfs workspaces created by git-tfs - since 0.10

  • help: get help on git-tfs commands - since 0.9

  • verify: verify the changesets fetched - since 0.11

  • autotag option - since 0.12

  • subtree: manage sparse tfs pathes with git-tfs - since 0.19

  • reset-remote: reset a tfs remote to a previous changeset to fetch again its history - since 0.19

  • checkout: checkout a commit by a changeset id - since 0.21

  • diagnostics (for git-tfs developers only) - since 0.9

  • config file

Building

Continuous Integration Status

AppVeyor build status ( Great thanks to AppVeyor Icon AppVeyor! )

Prerequisites

  • MSBuild (included in .NET 4)

And depending of the version of TFS you use :

Get the source code and build

#get the source code
git clone git://github.com/git-tfs/git-tfs.git
cd git-tfs

#building with MSBuild (with the default configuration: debug)
msbuild GitTfs.sln

#or building with MSBuild in release
msbuild GitTfs.sln /p:Configuration=release

#or with Rake (Ruby)
rake build:debug

Note: if the build fails because you don't have all the Visual Studio SDK, just unload in Visual Studio all the projects you are not interested in to be able to build and use your own version. You could also install, the Team Foundation Server Object Model for Tfs 2010 (chocolatey), Tfs 2012 (chocolatey) and Tfs 2013 (chocolatey).

Contributing

Contributions are always welcome. Thanks to all our contributors!

Please, read our short and simple guidelines and our doc on how to use paket, the package manager we use.

Especially, don't forget to set core.autocrlf to true (git config core.autocrlf true), and indentation using 4 spaces.

Migrations

If you're migrating a TFS server from 2008 or 2005 to 2010, you might want to Specify Alternate TFS URLs.

If you have questions or suggestions about how we could improve git-tfs you could go to google group.

Example of setting up central git repository that tracks TFS automatically.

Community

Drop in and chat in gitter We also have a mailing list.

S
Description
Languages
C# 99.2%
PowerShell 0.8%