$ git push
Username for 'https://github.com': Grand2015
To https://github.com/Grand2015/Leakage-simulation.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/Grand2015/Leakage-simulation.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.
关键部分简单翻译一下:
错误:无法推一些参考“https://github.com/Grand2015/Leakage-simulation.git”
提示:更新被拒绝,因为远程包含您没有本地的工作。
这通常是由另一个存储库推送到同一个引用引起的。
您可能希望首先集成远程更改(例如,“git pull ...”),然后再次推送。
有关详细信息,请参阅“git push --help”中的“关于快进的注意事项”。
原因很明了,git远端仓库被不同版本的本地仓库push了,解决这个问题先要对本地仓库与远端仓库进行合并,
执行指令:
git pull origin master
会出现对话框让你输入融合的理由
i 开始输入
esc:wq保存退出
$ git pull origin master
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/Grand2015/Leakage-simulation
* branch master -> FETCH_HEAD
b31ecb7..ed39b19 master -> origin/master
Merge made by the 'recursive' strategy.
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
融合完成,接着提交数据
$ git push
Username for 'https://github.com': Grand2015
Counting objects: 20, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (20/20), done.
Writing objects: 100% (20/20), 63.56 KiB | 0 bytes/s, done.
Total 20 (delta 14), reused 0 (delta 0)
remote: Resolving deltas: 100% (14/14), completed with 5 local objects.
To https://github.com/Grand2015/Leakage-simulation.git
ed39b19..bd61e7b master -> master
成功提交代码