在编辑了我的旧问题几次之后,我创建了一个新问题,因为它现在是一个新问题.
在.git/hooks/post-update我有:
echo "a" >> /home/pi/log
git update-server-info
git stash
git merge testing >> /home/pi/log
Run Code Online (Sandbox Code Playgroud)
进行自动结账.所以我在客户端上运行:
git push testing HEAD:testing
Run Code Online (Sandbox Code Playgroud)
现在我的/home/pi/log包含:
a
Updating ae2f44b..04753a9
Fast-forward
application/views/main/index.php | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
Run Code Online (Sandbox Code Playgroud)
但文件没有改变!
$ git merge testing
Already up-to-date.
Run Code Online (Sandbox Code Playgroud)
如果我删除脚本,进行推送和运行git stash,git merge testing它的工作原理.
更新
为了测试,我将文件中的数字从17更改为20.如果我运行,我可以看到正确的文件版本
git show application/views/main/index.php
Run Code Online (Sandbox Code Playgroud)
但
vim application/views/main/index.php
Run Code Online (Sandbox Code Playgroud)
仍包含旧号码.但是git声称该文件已更新:
$ git merge testing
Already up-to-date.
Run Code Online (Sandbox Code Playgroud)
编辑
看起来这是你的问题:
Run Code Online (Sandbox Code Playgroud)pre-receive update post-receive post-update这些挂钩可以在裸存储库或非裸存储库中运行.在这两种情况下,当前工作目录都是git目录.所以,如果这是一个名为"/src/git/test.git/"的裸存储库,那将是当前的工作目录 - 如果这是一个非裸存储库,并且工作树的顶层是"/ home"/mark/test /"那么当前的工作目录将是"/home/mark/test/.git/".
在这两种情况下,都会设置以下环境变量:
GIT_DIR设置为"."使用工作树,这出乎意料地尴尬,正如我之前链接的Chris Johnsen的回答所述.如果仅
GIT_DIR设置,则git手册页中的此注释适用:注意:如果
--git-dir或GIT_DIR指定但没有--work-tree,GIT_WORK_TREE和core.worktree指定,当前的工作目录被认为是你的工作树的顶端目录.换句话说,您的工作树也将是当前目录(".git"目录),这几乎肯定不是您想要的.
您可以尝试设置GIT_WORK_TREE=..或GIT_WORK_TREE="$GIT_DIR/.."挂钩内部
但文件没有改变!
最有可能的确如此.也许只有线性确实,或者在观看差异时忽略了空白变化,但确实发生了变化.Git知道,因为文件内容的SHA1总和发生了变化.
你在两端都使用Windows吗?
Windows倾向于混淆行结尾.请参阅core.autocrlf和相关选项:
| 归档时间: |
|
| 查看次数: |
4969 次 |
| 最近记录: |