Git:无法从一台计算机推送

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/398203/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:07:46  来源:igfitidea点击:

Git: Can't push from one computer

git

提问by Matt McMinn

One of my coworkers is having a problem pushing changes from git on his machine. If he logs into another machine, he can push just fine - but from his machine, when he tries to push he gets the following error

我的一位同事在他的机器上从 git 推送更改时遇到问题。如果他登录到另一台机器,他可以很好地推送 - 但是在他的机器上,当他尝试推送时,他会收到以下错误

    D:\Projects\test1\best-practices>git push
    Counting objects: 4, done.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 273 bytes, done.
    Total 3 (delta 1), reused 0 (delta 0)
    error: unable to create temporary sha1 filename ./objects/42: Permission denied

    fatal: failed to write object
    error: unpack failed: unpacker exited with error code
    To //civ3s012/gitrepos/best-practices/.git
     ! [remote rejected] master -> master (n/a (unpacker error))
    error: failed to push some refs to '//civ3s012/gitrepos/best-practices/.git'

The server is a windows machine, as is the client. No one else is having this problem - it seems to be a server permissions issue, but we've ruled that out as far as we can tell. Also, the fact that he can log into a different machine and push, using the same username, makes it seem like it's not server permissions. Any ideas what could be going wrong here?

服务器是 Windows 机器,客户端也是。没有其他人遇到这个问题 - 这似乎是一个服务器权限问题,但据我们所知,我们已经排除了这个问题。此外,他可以使用相同的用户名登录到不同的机器并进行推送,这一事实使得这似乎不是服务器权限。任何想法可能会出现什么问题?

采纳答案by Pat Notz

I'm not a windows user so I'm stabbing in the dark a little here. It looks like the remote file system is mounted and you're just pushing to that (not using ssh:// or git://). Is that FS somehow mounted readonly? Can he create/modify files on there (outside of git)?

我不是 Windows 用户,所以我在这里暗中刺伤。看起来远程文件系统已安装,您只是在推动它(不使用 ssh:// 或 git://)。那个 FS 是以某种方式以只读方式安装的吗?他可以在那里(在 之外git)创建/修改文件吗?

回答by Paul

Try adding this configuration variable to the remote repository:

尝试将此配置变量添加到远程存储库:

 $ git config core.sharedRepository "all"
 $ git config receive.denyNonFastForwards True

These are usually set by the --sharedoption in git init, when the repo is set up.

这些通常在设置repo 时由 中的--shared选项git init设置。

I don't know how windows permissions interact, so I'm not sure that this is the solution. But I know that sometimes a linux user can create files with permissions that fail in a Git remote in exactly this way. It happened when they belong to the proper group but don't have it as their primarygroup. Setting the repo sharing to allgets around this.

我不知道 Windows 权限如何交互,所以我不确定这是解决方案。但我知道,有时 linux 用户可以完全以这种方式创建具有在 Git 远程中失败的权限的文件。当他们属于适当的组但没有将其作为主要组时,就会发生这种情况。设置 repo 共享all可以解决这个问题。

This seems happen with shared repos imported from SVN or CVS.

这似乎发生在从 SVN 或 CVS 导入的共享存储库中。

回答by T.E.D.

I know this is the easy-peasy sysadmin blowoff answer, but have you verified that his harddrive isn't full?

我知道这是一个简单的系统管理员吹嘘的答案,但是您是否确认他的硬盘驱动器未满?

回答by Matt McMinn

The problem ended up being a stored password for that share which allowed read access, but not write access. Even when we explicitly mounted the drive with the appropriate username and password, the stored password must have been used in the background, which made this difficult to track down. To clear the password, we went to Control Panel, User Accounts, clicked on Advanced, Manage Passwords, and removed the logon information for the server in question. After that, everything worked as it should. I'm accepting Pat Notz's answer, since it did end up being a read-only FS. Thanks!

问题最终是该共享的存储密码允许读取访问,但不允许写入访问。即使我们使用适当的用户名和密码明确安装驱动器,存储的密码也必须在后台使用,这使得很难追踪。要清除密码,我们进入控制面板、用户帐户、单击高级、管理密码,然后删除相关服务器的登录信息。在那之后,一切都按预期进行。我接受 Pat Notz 的回答,因为它最终成为只读 FS。谢谢!

回答by gregf

Another brain dead answer. You sure you have permissions to read those files? Has happened to me a few times where I'll make a change as another user by mistake. Then later I can't push. Chown is your friend.

另一个脑死亡的答案。您确定您有权读取这些文件吗?在我身上发生过几次,我会错误地作为另一个用户进行更改。后来我推不动了。周是你的朋友。

回答by Otto

Maybe he's created a branch in his local repo that already exists on the server and that ref can't be updated because it was created by someone else?

也许他在服务器上已经存在的本地存储库中创建了一个分支,并且该引用无法更新,因为它是由其他人创建的?