简体   繁体   English

git diff无法在裸仓库中工作,后接收挂钩

[英]git diff not working on a bare repo, post-receive hook

I am working on a post-receive hook on a bare repo. 我正在处理裸仓库中的接收后挂钩。 I want to get the file names that are changed and pushed in this bare repo (only the latest one). 我想获取更改的文件名,并将其推送到该裸仓库(仅最新的仓库)中。 To get it i am using this command. 为了得到它,我正在使用此命令。

git diff --name-only HEAD^

This gives me error when I push to bare repo. 当我推送到裸仓库时,这给了我错误。

remote: fatal: This operation must be run in a work tree

I got that there is no worktree in bare repo so this command fails but how to get this run? 我知道裸仓库中没有工作树,所以该命令失败,但是如何运行呢?

I believe the command you are looking for is git diff --name-only HEAD^ HEAD . 我相信您要查找的命令是git diff --name-only HEAD^ HEAD This will compare the "current" commit with the commit before it. 这会将“当前”提交与之前的提交进行比较。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM