Eric Saboia Eric Saboia - 1 year ago 160
Git Question

Invalid name for a Git Refence

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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download