每个工作目录的 .git/ 权限
每次 git push 时都会出现此错误。仅适用于此工作目录。不是在另一个类似的地方,据我所知,那里具有相同的权限。
$ git push
Counting objects: 15, done.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (8/8), 683 bytes, done.
Total 8 (delta 5), reused 0 (delta 0)
remote: Sending mail...
To [email protected]:mysite.git
dd36358..86bc572 redesign -> redesign
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:mysite.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
这是权限问题吗? git pull 似乎工作正常,git push 似乎也可以通过,但我仍然收到错误。
有什么想法吗?
I get this error every time I git push. Only for this working directory. Not in another similar one, where from what I can tell has the same permissions.
$ git push
Counting objects: 15, done.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (8/8), 683 bytes, done.
Total 8 (delta 5), reused 0 (delta 0)
remote: Sending mail...
To [email protected]:mysite.git
dd36358..86bc572 redesign -> redesign
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:mysite.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
Is this a permissions issue? git pull seems to work fine and git push seems to go through too but I still get the error.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
咳咳
对我来说,这确实不像权限问题。
Ahem
This really doesn't look like a permissions problem to me.
这不是权限问题;查看错误消息:
git push --help 的“关于快进的注释”部分对这个问题有一个冗长的解释,但简而言之;您要推送到的分支不是当前分支的直接祖先,因此远程服务器不会让您推送。您需要修复本地更改(例如
git pull
来获取您丢失的更改,或者git rebase
将您的更改重新设置到远程头),或者强制远程服务器接受--force
的推送(后者几乎从来都不是正确的举动)It's not a permissions issue; see the error message:
The "note about fast-forwards" section of
git push --help
has a lengthy explanation of the problem, but in short; the branch you're pushing to isn't a direct ancestor of your current branch, so the remote server won't let you push. You need to fix your local changes (e.g.git pull
to get changes you're missing, orgit rebase
to rebase your changes onto the remote head), or force the remote server to accept the push with--force
(the latter is almost never the right move)如果这仍然是一个问题,如果您执行 git push,您将推送所有分支,而不仅仅是当前分支。
然而,
git pull
并不与git push
直接相反。它与执行以下命令完全相同:即 git pull 只合并工作分支。它不合并任何其他分支。
如果 git pull 没有问题,但你仍然无法推送,这意味着你的其他分支之一已经过时了,这就是 git 抱怨的。
解决方案是仅推送当前分支:
请注意,我假设
thecurrentbranch
是您的活动分支的名称,origin
是您的上游存储库。编辑:仔细看看你原来的问题是有启发性的:
你可能已经签出
redesign
,所以这就是git pull
正在操作的内容。然而,git 拒绝了master
分支。因此,要解决这个特定问题,要么明确地推动重新设计,要么执行以下操作:In case this is still a problem, if you do
git push
, you're pushing all your branches, not just the current one.git pull
is NOT a direct opposite togit push
, however. It is exactly the same as doing the following commands:That is,
git pull
only merges the working branch. It does NOT merge any other branches.If
git pull
comes up clean, but you still can't push, it means that one of your other branches is out of date, and that's what git is complaining about.The solution is to only push your current branch:
Note that I assume
thecurrentbranch
is the name of your active branch, andorigin
is your up-stream repository.EDIT: Taking a close look at your original question is enlightening:
You probably have
redesign
checked out, and so this is whatgit pull
is operating on. However, git is rejecting themaster
branch. So, to resolve this specific problem, either pushredesign
explicitly, or do this: