Git 在 MacOS 上执行 git rm 后提交后恢复文件
Git on MacOS restoring file after commit when doing a git rm
运行宁 MacOs High Sierra 10.13.4 和 git 版本 2.17.0.
这是我的工作流程:
git rm ./some/file.out
- 运行
git status
看到 ./some/file.out
的删除正在等待提交
- 查看
ls ./some/
,发现文件已被删除
- 运行
git commit
并看到消息一个文件已被删除
但是:
- 如果我然后 运行
git status
我看到文件仍然存在但未被跟踪。
- 当 运行
git clean -df
在未跟踪的文件上时,它会被删除并且不会 return。
我也试过了
- 删除非git
rm ./some/file.out
的文件
- 运行
git add .
然后 git commit
并查看文件删除消息
- 运行
git status
并显示文件仍然存在,但未被跟踪
这似乎是最近才开始发生的。
这是我的 git 配置:
credential.helper=osxkeychain
core.hookspath=/Users/myname/.git_hooks
core.excludesfile=/Users/myname/.gitignore
user.email=myname@somewhere.com
color.ui=true
color.branch=true
color.status=true
color.diff=true
color.interactive=true
color.grep=true
color.pager=true
color.decorate=true
color.showbranch=true
alias.pt=!git push -u origin `git rev-parse --abbrev-ref HEAD`
alias.co=checkout
alias.cob=checkout -B
alias.b=branch
alias.bd=branch -D
可能发生了什么——具体来说,有没有其他人看到过类似的东西并发现它与 git 相关?
只是在终端中删除文件(非git repo 文件)没有这种行为。
查看我的 ~/.git_hooks
。看起来我的 ~/.git_hooks/pre-commit.d
文件夹中调用的脚本是罪魁祸首。
不确定脚本到底在做什么(或应该做什么),但是当我删除脚本时,git rm && git commit
功能按预期工作——不再有文件起死回生!
运行宁 MacOs High Sierra 10.13.4 和 git 版本 2.17.0.
这是我的工作流程:
git rm ./some/file.out
- 运行
git status
看到./some/file.out
的删除正在等待提交 - 查看
ls ./some/
,发现文件已被删除 - 运行
git commit
并看到消息一个文件已被删除
但是:
- 如果我然后 运行
git status
我看到文件仍然存在但未被跟踪。 - 当 运行
git clean -df
在未跟踪的文件上时,它会被删除并且不会 return。
我也试过了
- 删除非git
rm ./some/file.out
的文件
- 运行
git add .
然后git commit
并查看文件删除消息 - 运行
git status
并显示文件仍然存在,但未被跟踪
这似乎是最近才开始发生的。
这是我的 git 配置:
credential.helper=osxkeychain
core.hookspath=/Users/myname/.git_hooks
core.excludesfile=/Users/myname/.gitignore
user.email=myname@somewhere.com
color.ui=true
color.branch=true
color.status=true
color.diff=true
color.interactive=true
color.grep=true
color.pager=true
color.decorate=true
color.showbranch=true
alias.pt=!git push -u origin `git rev-parse --abbrev-ref HEAD`
alias.co=checkout
alias.cob=checkout -B
alias.b=branch
alias.bd=branch -D
可能发生了什么——具体来说,有没有其他人看到过类似的东西并发现它与 git 相关?
只是在终端中删除文件(非git repo 文件)没有这种行为。
查看我的 ~/.git_hooks
。看起来我的 ~/.git_hooks/pre-commit.d
文件夹中调用的脚本是罪魁祸首。
不确定脚本到底在做什么(或应该做什么),但是当我删除脚本时,git rm && git commit
功能按预期工作——不再有文件起死回生!