1

I tried publish my branch in the remote repository with visual studio 2015, but returned this error:

The following errors were reported during push:
refs/heads/feature/EricSaboia, TF401021: 'refs/heads/feature/EricSaboia' is not a valid name for a Git ref in this context.

I'm use Git in TFS repository and I didn't find much about it in the web.

What happened?

lance
  • 16,092
  • 19
  • 77
  • 136
Eric Saboia
  • 301
  • 2
  • 10
  • 22
  • Are you using GIT command or through GUI? And did you have a mapping relationship with your local branch and remote branch? – PatrickLu-MSFT Aug 24 '16 at 01:59

2 Answers2

2

If you are using GUI, make sure you have select a right button for your situation

  • Publish: when there is not a branch on the remote repo associated with the current local branch. This will create a branch with the same name on the remote repo and push the commits to it. Later you will Push, not publish changes when using this branch since the relationship between the branch on the local branch and the remote repo exists.
  • Push: when there is a relationship between the local branch and the remote repo. Clicking this will push the commits to the remote branch.

You can also try it with GIT command:

The push command will update the remote branch on origin with the commits from your local branch.

git push

If the remote branch doesn't exist, run the following to create a remote branch on origin.

> git push -u origin refs/heads/feature/EricSaboia

Your commits on your local branch are added to the branch on origin, and a upstream tracking relationship will be set up in Git so that next time you push (or pull) from this local branch, you won't have to specify the remote branch name.

If it's still not work, you can try to run a git fetch command before the push, more detail way and info please refer to this similar question git push origin gives remote part of refspec is not a valid name

Community
  • 1
  • 1
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
0

Okay, I had this same error message too when trying to commit to Git via TortoiseGit and from the command-line. It turns out the error was caused by me wanting to pick a branch name that was already being used as a 'directory' for other refs.

Specifically, I was trying to create a branch release, but there already existed branches called release/sprint1 and release/sprint2 on the server. Since it's impossible to have a folder and a file with the same name in the same place on Windows, that makes sense... although the error message could have been more helpful (as is always the case with Microsoft products!)

BoffinBrain
  • 6,337
  • 6
  • 33
  • 59