尝试将更改推送到 GitHub,但出现错误
Trying to push the changes on GitHub, but I am getting an error
考虑:
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/dvtta/pinter.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
我也有这个问题...输出让我感到惊讶:
git push github master
To git@github.com:Joey-project/project.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:Joey-project/project.git'
如果我没记错的话,一般的方法是使用以下命令的变体:
git fetch github; git merge github/master
看看 How to commit after removing a directory from GIT 可能会有帮助,它给了我一个很好的基本想法。
Problem reason
您正在尝试推送到尚未与其同步的远程存储库。所以要么先拉再推....
做一个git pull
然后git push
The hard way to resolve this (Don't do it until you have to)
git push -f
上面的命令将删除你不同步的东西。换句话说,您没有的所有这些提交都将通过此命令从存储库中删除。
所以不要使用它除非你不得不这样做。
考虑:
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/dvtta/pinter.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
我也有这个问题...输出让我感到惊讶:
git push github master
To git@github.com:Joey-project/project.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:Joey-project/project.git'
如果我没记错的话,一般的方法是使用以下命令的变体:
git fetch github; git merge github/master
看看 How to commit after removing a directory from GIT 可能会有帮助,它给了我一个很好的基本想法。
Problem reason
您正在尝试推送到尚未与其同步的远程存储库。所以要么先拉再推....
做一个git pull
然后git push
The hard way to resolve this (Don't do it until you have to)
git push -f
上面的命令将删除你不同步的东西。换句话说,您没有的所有这些提交都将通过此命令从存储库中删除。
所以不要使用它除非你不得不这样做。