我正在通过我正在上课的git首次介绍git.我的计算机上的目录中有许多文件,并且能够毫无问题地暂存和提交它们.但是,当我尝试将文件推送到我的github存储库时,我继续收到此消息:
Pushing to https://github.com/BigMeanCat/CMDA
To https://github.com/BigMeanCat/CMDA
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/BigMeanCat/CMDA'
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.
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决这个问题以及如何解决这个问题?我在网上看到过一些有类似问题的人,但我对git并不熟悉,还不熟悉git的命令行语言.我对采取某些建议犹豫不决,因为我不知道它是否会解决问题或使情况变得更糟.
谢谢!
Tun*_*ğlu 15
其他人(或其他机器上的某个人)已将变更集推送到远程存储库.你,在你的本地机器上还没有那些变化.所以要解决你首先要做的情况
git pull
Run Code Online (Sandbox Code Playgroud)
然后
git push
Run Code Online (Sandbox Code Playgroud)
但是,您将无法git pull同时你有你的工作树的变化,所以你拉/推之前,你首先要commit和stash当地的变化.如果远程更改与您的本地更改重叠,这可能会导致合并情况.
小智 15
我遇到了同样的错误,然后用"--force"命令解决了这个问题.简而言之,写下这个命令;
git push origin master --force
Run Code Online (Sandbox Code Playgroud)
注意:可能你之前尝试过一次又一次地推送你的代码,这就是你犯这个错误的原因.我的解决方案强有力地用你的变更集覆盖.通过这种方法,您的存储库可能会导致其他人不匹配.但是如果你单独工作(而不是像工作小组一样),那么你可以轻松地使用"--force",如上所述.
| 归档时间: |
|
| 查看次数: |
39454 次 |
| 最近记录: |