【问题标题】:How I can update changes on remote git repository?如何更新远程 git 存储库上的更改?
【发布时间】:2012-10-19 10:56:22
【问题描述】:

我完成了在远程 git 存储库上提交和推送更改,但是当我查看远程存储库的文件时,这些文件已经过时了。我正在使用 Git Bash。

View image

红色文本是在存储库克隆中所做的更改。这些更改不会反映在原始存储库的物理文件中

我该如何反映这些变化?

【问题讨论】:

  • 你的推送成功了吗?您的命令的结果可能有用。
  • 很奇怪...当克隆服务器存储库时,我可以提交最后的更改。但是当我查看服务器存储库中的文件时,它并没有改变...我使用 Egit 推送更改...一切似乎都正确
  • 您可以发布您的图片地址以“.png”结尾吗?我将能够在您的问题中为您导入它。但我在工作中看不到 tinypic.com(被屏蔽)

标签: git commit git-push git-clone git-remote


【解决方案1】:

我假设您正在推送到远程当前正在签出的分支。因为它看起来像是一个非裸存储库,并且在您的描述中有文件签出。

我做了一些简单的测试来模拟这样的推送,显示如下信息:

remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.

如果您确定推送成功(默认情况下会被拒绝),那么您必须在远程存储库中执行以下操作。

git reset --hard

【讨论】:

  • 感谢您的帮助 =)。我的错误是将服务器存储库创建为普通存储库而不是裸存储库。我不知道裸存储库...顺便说一下,在裸存储库中,文件以二进制形式存储?我没有看到工作目录
  • 裸存储库中只有提交对象,通常您永远不会签出远程存储库中的任何文件,它唯一的工作就是保存提交。如果您想在每次推送时将其部署到集中式开发环境或其他东西中,也许您可​​以在裸存储库中添加一个挂钩来为您执行此操作。此外,您将在更新后或接收后挂钩中执行此操作,具体取决于您的 git 版本。
猜你喜欢
  • 2020-07-13
  • 2011-01-26
  • 1970-01-01
  • 2012-12-25
  • 2010-10-29
  • 1970-01-01
相关资源
最近更新 更多