2012-05-10 46 views
1

在我的本地機器上,我克隆了一個遠程回購,進行了一些更改,提交,然後推回到尚未被觸摸的遠程回購以任何方式在此期間。Git推送到遠程原點 - 更改不是在原點提交,只在git存儲後可見

在遠程機器上查看遠程回購時,我看不到我所做的更改。 git status告訴我有可能發生的變化。當我查看這些文件時,我看不到我做出的任何更改。當我在遠程分支中執行git stash時,我看到了更改。所以不知何故,git不會在遠程回購中提交推送的更改。

難道有人請向我解釋這背後的邏輯,以及我如何避免這種情況?我能以某種方式將更改推送到遠程回購,而無需git stash

非常感謝您的澄清!

回答

2

如果您推入帶有結賬工作副本的遠程,您將不會自動查看更改。 git正在將更改推送到存儲庫.git目錄)。如果要更新關聯的工作副本,則需要在post-update鉤子中實現適當的邏輯。

一般來說,git甚至不會讓你推與不明確的配置相關的工作拷貝遙控...你通常會發現線沿線的一個錯誤:

remote: error: refusing to update checked out branch: refs/heads/master 
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. 
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set 
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. 
To /home/lars/repo1 
! [remote rejected] master -> master (branch is currently checked out) 
error: failed to push some refs to '/home/lars/projects/administrivia/repo1' 
+1

要添加到此,你通常應該只推送由'git init --bare'創建的倉庫,並讓其他人從那裏抽取。或者,如果你不喜歡那樣,只需拉動,不要推。推動非裸回購是奇怪和蹩腳的。 – Dougal

+0

http://sitaramc.github.com/concepts/bare.html 這是一個非常好的解決我的問題。 – Eekhoorn

+0

難道這是舊版git版本的問題嗎?我的工作場所有git版本1.5.6.5,而在我的Mac上運行1.7.4.4。 – Eekhoorn