如何更新远程git存储库的更改?

时间:2012-10-30 05:41:01

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

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

View image

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

如何反映这些变化?

1 个答案:

答案 0 :(得分:2)

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

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

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