git pull origin master返回致命:refspec无效

jhn*_*ylr 9 git macos terminal github refspec

这是问题所在:

每当我这样做

$ git pull 'https://github.com/username/reponame.github.io.git'

其次是网址我没有遇到任何问题,但是当我这样做时

git pull origin master 'https://github.com/username/reponame.github.io.git'

然后是它返回的url

fatal: Invalid refspec 'https://github.com/username/reponame.github.io.git'

这是什么意思,我该如何解决它?

miq*_*iqh 6

如果您已经建立了远程跟踪分支(即git clone自动执行此操作)并希望使用git pull以获取远程存储库中当前分支的最新提交,我相信执行以下操作就足够了:

git pull
Run Code Online (Sandbox Code Playgroud)

为了达到同样的效果,包含refspec(不必要的冗长):

// Pulls the remote 'master' branch down to the local 'master' branch
git pull origin master:refs/remotes/origin/master
Run Code Online (Sandbox Code Playgroud)

您收到该错误,因为提供URL不是refspec格式化的方式.

有关refspec如何工作及其语法的更多详细信息,请参阅精彩的Pro Git一书中的本章.希望有所帮助!