What if your team uses TFS, but you want offline support? You can have a Git repo as well, but then getting your changes to TFS is burdensome. Here’s where a GIT to TFS bridge would be handy.
Here’s how to keep a TFS repository foo, and a GIT repository bar, in sync. First step is you need to create a new TFS workspace:
cd \
tf workspace /new /noprompt Foo
Now you should place your .git folder from the root of your git repo in the root of your TFS repo. If you don’t have the git repo locally, you can get it like this:
cd \temp
git clone [email protected]:yourusername/yourgitrepo.git
cd yourgitrepo
copy .git \Foo
rmdir /S yourgitrepo
Then you’ll want to sync the TFS repo up with what was in the GIT repo
cd \Foo
git reset –hard
Or if you want to do the other-way around:
cd \Foo
tf get /overwrite
At this point you should have no pending changes from either TFS or GIT.
If you want to do some work in GIT, and then eventually push to TFS, here’s how you’d do it:
First, make sure TFS is updated:
tf get /overwrite
Next, make sure your GIT code is updated:
git pull
Tell TFS about all the git changes
tfpt online . /recursive /adds /deletes /diff
Make a shelveset with all the pending changes
tf shelve
Run whatever command executes your tests, and checks in the code
Let’s say someone has checked in something into TFS which you want in GIT.
Make sure git is updated:
git pull
Overwrite your git repo with TFS:
tf get /overwrite
As that runs, you’ll see a list of files coming in. Now you need to tell git about them:
git add .
Now, commit that to git:
git commit -a -m “Sync to head of TFS”
Run all your tests, and if they pass, push it out to the remote repo:
git push
Yep, not sure if that was around at the time, but thanks for the pointer!