Git 引用的名称无效
Invalid name for a Git Reference
我尝试使用 visual studio 2015 在远程存储库中发布我的分支,但返回此错误:
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.
我在 TFS 存储库中使用 Git,但我在网上找不到太多相关信息。
发生了什么事?
如果您使用的是 GUI,请确保您有 select 适合您情况的正确按钮
- 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.
你也可以用GIT命令试试:
push
命令将使用本地分支的提交更新 origin 上的远程分支。
git push
如果远程分支不存在,运行下面在origin
上创建一个远程分支。
> git push -u origin refs/heads/feature/EricSaboia
您在本地分支上的提交将添加到 origin
上的分支,并且将在 Git 中建立上游跟踪关系,以便下次您 push
(或pull
) 从这个本地分支,你将不必指定远程分支名称。
如果还是不行,你可以尝试运行一个git fetch
命令再推送,更详细的方法和信息请参考这个类似的问题git push origin gives remote part of refspec is not a valid name
好的,当我尝试通过 TortoiseGit 和从命令行提交到 Git 时,我也收到了同样的错误消息。原来这个错误是由于我想选择一个已经被其他引用用作 'directory' 的分支名称引起的。
具体来说,我试图创建一个分支 release
,但服务器上已经存在名为 release/sprint1
和 release/sprint2
的分支。由于在 Windows 上的同一位置不可能有同名的文件夹和文件,这是有道理的......尽管错误消息可能更有帮助(微软产品总是如此! )
我尝试使用 visual studio 2015 在远程存储库中发布我的分支,但返回此错误:
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.
我在 TFS 存储库中使用 Git,但我在网上找不到太多相关信息。
发生了什么事?
如果您使用的是 GUI,请确保您有 select 适合您情况的正确按钮
- 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.
你也可以用GIT命令试试:
push
命令将使用本地分支的提交更新 origin 上的远程分支。
git push
如果远程分支不存在,运行下面在origin
上创建一个远程分支。
> git push -u origin refs/heads/feature/EricSaboia
您在本地分支上的提交将添加到 origin
上的分支,并且将在 Git 中建立上游跟踪关系,以便下次您 push
(或pull
) 从这个本地分支,你将不必指定远程分支名称。
如果还是不行,你可以尝试运行一个git fetch
命令再推送,更详细的方法和信息请参考这个类似的问题git push origin gives remote part of refspec is not a valid name
好的,当我尝试通过 TortoiseGit 和从命令行提交到 Git 时,我也收到了同样的错误消息。原来这个错误是由于我想选择一个已经被其他引用用作 'directory' 的分支名称引起的。
具体来说,我试图创建一个分支 release
,但服务器上已经存在名为 release/sprint1
和 release/sprint2
的分支。由于在 Windows 上的同一位置不可能有同名的文件夹和文件,这是有道理的......尽管错误消息可能更有帮助(微软产品总是如此! )