4

I'm trying to migrate from TFVC (Visual Studio Team Services) to git (hosted via Visual Studio Team Services). I've been able to build a script which migrates all the stuff, branches, does some cleanup etc. I used git tfs (https://github.com/git-tfs/git-tfs/blob/master/doc/usecases/migrate_tfs_to_git.md) and a few online blog posts.

Everything works like a charm except when I try to cleanup commit messages I get a "fatal: bad revision s/^git-tfs-id:.*$//g" using the command from the doc git filter-branch -f --msg-filter 'sed "s/^git-tfs-id:.*$//g"' -- --all

I've been trying to play around with the regex, it doesn't solve the issue. After digging a lot on the internet I still can't understand why it's not working properly. I'm using git for windows command line (latest version) and my knowledge of git is pretty basic, but I couldn't find any alternative to achieve what I want to do.

Thanks for your help!

Esther Fan - MSFT
  • 8,276
  • 4
  • 27
  • 25
baywet
  • 4,377
  • 4
  • 20
  • 49

2 Answers2

2

Finally found what the actual issue was... A quote issue git filter-branch -f --msg-filter 'sed "s/git-tfs-id:.*//gm"' -- --all
doesn't work git filter-branch -f --msg-filter "sed 's/git-tfs-id:.*//gm'" -- --all works

I guess there is an compatibility issue between the interpretation of quotes of windows command line and Git virtual bash.

Regardless thanks @Giuseppe Ricupero for your help!

baywet
  • 4,377
  • 4
  • 20
  • 49
0

The command you're trying to execute rely on an external tool: the sed executable (available by default on most unix flavours but not on windows): probably you have to install sed on your own.

Get a windows-compatible version of sed from one of these unix-tools bundles:

  1. UnxUtils (latest update 2013, medium size)
  2. Cygwin (constantly updated, the default choice if you don't mind about size)
  3. GnuWin32 (latest update 2010)

Hope this helps!

Giuseppe Ricupero
  • 6,134
  • 3
  • 23
  • 32
  • Thanks for answering. I thought the Git for Windows installation would bring some of the tools with it (maybe I checked something wrong during the installation process?) Does this mean I could technically replace that with some equivalent PowerShell? – baywet Jan 08 '16 at 16:41
  • @baywet: This may work but it's untested: ``git filter-branch -f --msg-filter '% { $_ -replace "^git-tfs-id:.*$","" }' -- --all`` – Giuseppe Ricupero Jan 08 '16 at 17:35