1

We use TFS 2010 at work, and I use git-tfs so I can use git locally. I've recently upgraded my machine, and copied all my local repository folders across.

I seem to be able to pull from TFS and commit locally. However when I do git tfs rcheckin, I now get the error:

TF26198: The work item does not exist, or you do not have permission to access it.

It does however work when using git tfs checkintool.

I presumed that I was getting this error because the original git tfs clone was done on another computer. Reading the git-tfs docs, it sounds like I should be doing a git clone from my old machine (rather than copy), then a git tfs bootstrap. However, when trying this, I still get the same error.

Any ideas what could be causing this? The only other difference I can think of is that my old machine has VS2010 and VS2012 installed, whereas my new machine has just VS2012 installed.

Dan
  • 5,692
  • 3
  • 35
  • 66
  • Does git-tfs try to do work item linking from "mentions" like #1234? If so, is there a comment to that effect in one of the commits being checked in? – Edward Thomson Feb 01 '14 at 19:23
  • Do you mean have I added a comment with a # followed by a number? I always format my commit message like this: "[#1234] my commit message". So yes, my comments do match what you ask. However, I've always done that, and it worked fine on my old machine. – Dan Feb 01 '14 at 22:22
  • At the risk of repeating the message: are you certain you typed the work item number correctly? Are you certain that git-tf is running as the user you think it is? Are you certain that you actually have permission to both read and write that work item? – Edward Thomson Feb 01 '14 at 23:34
  • Sorry, I missed out a key bit of information in my comment! I meant to say that the the hash number relates to our bug tracking system's ticket number. It's nothing to do with work items. I never explicitly specific work flow stuff. This wasn't an issue on my old machine though. Also I must have permissions as git tfs checkintool works. – Dan Feb 02 '14 at 05:02

2 Answers2

9

git-tfs parses your commit comments to provide work item associations with your changesets. By default, if you enter #1234, then the git-tfs checkin and rcheckin commands will attempt to associate work item 1234 with the checkin.

If you are using #1234 in your commit messages in order to associate these with a different bug tracking system, this is obviously in conflict. In this particular case, git-tfs cannot find the TFS work item and is providing you with this message.

As of recently, you can provide a configuration value:

git-tfs.work-item-regex

in order to override the #1234 behavior. While there is no way to disable this functionality, you can set it to something you would be unlikely to conflict with. For example:

git-tfs.work-item-regex=TFS WORK ITEM:(?<item_id>\d+)
Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
  • Interesting - I never knew about this. Seems an odd default behaviour, given that most people will want to put bug tracker ids in their commit messages. I also don't understand why I didn't hit this problem on my old machine. I'll give it a go when I get to work tomorrow and update here once I've tested it. Thanks for this. – Dan Feb 02 '14 at 09:33
  • I think because most people using TFS for version control also use TFS for their bug tracker. Regardless, it looks like a recent addition to git-tf, possible that your old machine had an older version that lacked this feature. – Edward Thomson Feb 02 '14 at 17:26
  • Note that we have not released the version with this feature so if the problem come from there (which is most likely), you will have to build your own version or avoid syntax with `#id` until we release a new version... – Philippe Feb 03 '14 at 02:51
  • I've changed it to start with [1234] instead, and that seems to work. I'll setup the regex once it has been released. Thanks for the help with this. – Dan Feb 03 '14 at 12:13
  • 2
    Example: from git-bash run this: `git config git-tfs.work-item-regex 'buggerofftfs'`, then retry your checkin. This regex won't match anything (well, almost anything) – Tim Abell Feb 23 '15 at 20:53
  • config documentation https://github.com/git-tfs/git-tfs/blob/master/doc/config.md – Tim Abell Feb 23 '15 at 20:53
  • Thanks for this answer. I'd like to add that you can trigger this problem accidentally if your commit message includes a URL with a "named anchor" in it. Such as stackoverflow.com/somepage#someanchor – Mark F Guerra Apr 25 '16 at 20:17
-2

I presumed that I was getting this error because the original git tfs clone was done on another computer. Reading the git-tfs docs, it sounds like I should be doing a git clone from my old machine (rather than copy), then a git tfs bootstrap. However, when trying this, I still get the same error.

It will change nothing because it's a problem when git-tfs interact with TFS...

Any ideas what could be causing this? The only other difference I can think of is that my old machine has VS2010 and VS2012 installed, whereas my new machine has just VS2012 installed.

Update: See the other answer by @ethomson which is indeed the good answer...

Philippe
  • 28,207
  • 6
  • 54
  • 78