在 Windows 上,我通常的工作流程是:
git init
git pull https://<repo_address> "branch_name"
git commit --all -m"message"
git push https://<repo_address> "branch_name"
执行完所有分支测试后, merge 到master,比方说
git checkout master
或者只是 cd 到另一个目录并 merge
git pull https://<repo_address> "branch_name"
在 Windows 上它运行完美。然而,当我将我的应用程序移植到 Linux 时,令人惊讶的是我在推送我的分支时卡住了
git init
git pull https://<repo_address> "branch_name"
git commit --all -m"message"
git push https://<repo_address> "branch_name"
得到众所周知的错误
error: src refspec branch_name does not match any.
error: failed to push some refs to 'https://<repo_address>'
我找到了几个解决方案,但没有一个适合我。不确定原因是操作系统,可能只是不同的版本或其他原因。
在 Linux git 版本 2.1.4 上
最佳答案
我建议做一个克隆(它会 pull 下存储库和所有分支),或者如果你只想获得一个分支,你可以只添加远程然后获取分支。克隆可能是最简单的,但如果您只想要单个分支,则可以执行以下步骤。
git init
git remote add -t <branch_name> -f origin https://<repo_address>
git checkout <branch_name>
然后你可以提交和推送。
关于linux - Git:错误 src refspec 不匹配; Windows 和 Linux 上的不同行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39472230/