我是GitHub的新手.今天我在尝试将代码推送到GitHub时遇到了一些问题.
Pushing to git@github.com:519ebayproject/519ebayproject.git
To git@github.com:519ebayproject/519ebayproject.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:519ebayproject/519ebayproject.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)
我还没有在存储库中推送任何东西,为什么我需要拉东西呢?
虽然像"git log"这样的命令会很乐意接受同一参考的不同表达式,例如
refs/heads/master
heads/master
master
Run Code Online (Sandbox Code Playgroud)
对于"git update-ref",情况并非如此.例如
git update-ref master HEAD^
Run Code Online (Sandbox Code Playgroud)
是不一样的
git update-ref refs/heads/master HEAD^
Run Code Online (Sandbox Code Playgroud)
第一个命令创建一个新的ref .git/master(反过来引入了关于refs/heads/master的歧义).只有第二个命令真正更新了主人的脑袋.(git的/参/头/主)
为什么git update-ref接受没有"refs /"前缀的引用?是否应该至少有警告或命令行选项来强制创建此类引用?
我花了很长时间才弄明白为什么
git update-ref master HEAD^
Run Code Online (Sandbox Code Playgroud)
没有按预期工作.