为什么我需要强制git同步我的远程存储库? [英] Why do I need to force git to sync my remote repository?
问题描述
我有一个本地存储库,我从远程存储库中克隆(全部在一台机器上)。我想确保我的远程存储库从我的本地存储库中选择了更改,所以我做了一个 git push origin
。
我将工作目录更改为远程存储库;更改已传播到日志文件中(即,执行 git log
显示更改),但我的实际工作目录未显示更改。我做了一个 git checkout HEAD
,但CWD仍然没有改变。直到我做了一个 git checkout --force HEAD
,CWD同步了。
我怀疑这是因为远程存储库不是裸存储库。所以有两个问题:
- 是否有一种方法可以使远程存储库自动同步(即放弃本地更改)在
git push
? - 为什么我需要使用
--force
来获取它同步?什么应该是同步它的过程?
如果你的push(非裸)回购成功,这是因为:
receive.denyCurrentBranch
被设置为 false 或
忽略
在 git config
在后一种情况下,任何当前的本地修改不会被该推送删除。
只有一个 git checkout --force
会将工作目录重置为引用的实际索引内容通过 HEAD
。
确保两个非裸回购的同步方式通常是通过添加一个中间裸回购(你推)与一个后接收钩将去实际的远程回购(非巴并且从更新后的裸露回购库中 pull 。
通常的例子:
当您拉动时,请确保取消设置 I have a local repository that I've cloned from my remote repository (all on one machine). I wanted to make sure that my remote repository picked the changes from my local repository so I did a I changed my working directory to my remote repository; the change had propagated to the log file (i.e. doing I suspect this is happening because the remote repository isn't a bare repository. So two questions:
If your push (to a non-bare) repo succeeded, it is because: In the latter case, any current local modification wouldn't be erased by that push. The usual way to ensure synchronization between two non-bare repo is by adding an intermediate bare repo (to which you push) with a post-receive hook which will go the actual remote repo (the non-bare one) and pull from the updated bare repo. When you are pulling, make sure to unset 这篇关于为什么我需要强制git同步我的远程存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! GIT_DIR
:参见卡尔从$ git 更新后
钩子 $ git pull b
git push origin
.git log
showed the change) but my actual working directory didn't show the change. I did a git checkout HEAD
but the CWD still didn't change. It wasn't until I did a git checkout --force HEAD
that the CWD synced up.
git push
?--force
to get it to sync up? What should be the process of syncing it up?
receive.denyCurrentBranch
was set to false
or ignore
in the git config
Only a git checkout --force
would reset the working directory to the actual index content referenced by HEAD
.
The usual example: Using Git to manage a web site, which I use in:
GIT_DIR
: see "Calling 'git pull
' from a git post-update
hook"