每个工作目录的 .git/ 权限

发布于 2024-11-27 11:46:40 字数 1014 浏览 2 评论 0原文

每次 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鸢与 2024-12-04 11:46:40

咳咳

在再次推送之前合并远程更改(例如“git pull”)。

对我来说,这确实不像权限问题。

Ahem

Merge the remote changes (e.g. 'git pull') before pushing again.

This really doesn't look like a permissions problem to me.

七禾 2024-12-04 11:46:40

这不是权限问题;查看错误消息:

错误:无法将某些引用推送到“[电子邮件受保护] :mysite.git'
为了防止您丢失历史记录,非快进更新被拒绝
在再次推送之前合并远程更改(例如“git pull”)。请参阅
有关详细信息,请参阅“git push --help”的“有关快进的注意事项”部分。

git push --help 的“关于快进的注释”部分对这个问题有一个冗长的解释,但简而言之;您要推送到的分支不是当前分支的直接祖先,因此远程服务器不会让您推送。您需要修复本地更改(例如 git pull 来获取您丢失的更改,或者 git rebase 将您的更改重新设置到远程头),或者强制远程服务器接受 --force 的推送(后者几乎从来都不是正确的举动)

It's not a permissions issue; see the error message:

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.

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, or git 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)

谁人与我共长歌 2024-12-04 11:46:40

如果这仍然是一个问题,如果您执行 git push,您将推送所有分支,而不仅仅是当前分支。

然而,git pull 并不与 git push 直接相反。它与执行以下命令完全相同:

git fetch
git merge origin/thecurrentbranch

即 git pull 只合并工作分支。它不合并任何其他分支。

如果 git pull 没有问题,但你仍然无法推送,这意味着你的其他分支之一已经过时了,这就是 git 抱怨的。

解决方案是仅推送当前分支:

git push origin thecurrentbranch

请注意,我假设 thecurrentbranch 是您的活动分支的名称,origin 是您的上游存储库。

编辑:仔细看看你原来的问题是有启发性的:

dd36358..86bc572  redesign -> redesign
! [rejected]        master -> master (non-fast-forward)

你可能已经签出redesign,所以这就是git pull正在操作的内容。然而,git 拒绝了 master 分支。因此,要解决这个特定问题,要么明确地推动重新设计,要么执行以下操作:

git checkout master
git merge origin/master
git push

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 to git push, however. It is exactly the same as doing the following commands:

git fetch
git merge origin/thecurrentbranch

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:

git push origin thecurrentbranch

Note that I assume thecurrentbranch is the name of your active branch, and origin is your up-stream repository.

EDIT: Taking a close look at your original question is enlightening:

dd36358..86bc572  redesign -> redesign
! [rejected]        master -> master (non-fast-forward)

You probably have redesign checked out, and so this is what git pull is operating on. However, git is rejecting the master branch. So, to resolve this specific problem, either push redesign explicitly, or do this:

git checkout master
git merge origin/master
git push
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文