您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页git提交代码时src refspec feature does

git提交代码时src refspec feature does

来源:二三娱乐

用Git提交代码时候,pull的时候是没问题的,到commit后push的时候终端报出这样的问题:src refspec feature does not match any.

如下所示:

drydeMBP:xxx dry$ git pull origin feature
From 192.168.1.xxx:ios/xxx.git
 * branch            feature    -> FETCH_HEAD
Already up-to-date.
drydeMBP:DingDingReconstruction dry$ git push origin feature
error: src refspec feature does not match any.
error: failed to push some refs to 'git@192.168.1.xxx:ios/xxx.git'

解决

git branch -a 查看一下本地和远程分支

drydeMBP:xxx dry$ git branch -a
* feature
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/feature
  remotes/origin/master

发现远程有一个feature的分支,但是本地只有master分支。也就是说我们将本地master分支的代码要push到远程的feature分支上,所以出问题。

我的解决办法是基于远程feature分支创建了一个本地的feature分支,然后再从本地feature分支push到远程feature分支就ok了。

(1)首先基于远程feature分支创建本地对应的分支
git branch feature origin/feature

(2)切换到feature分支上
git checkout feature

(3)push
git push origin feature

总结

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务