如何通过重命名来追踪文件的修订版本? [英] How do I cat revisions of a file, following it through renames?
问题描述
我可以做到这一点:
git log --format =%h - filename |同时读f;做git show $ f:filename;完成
但是,如果我尝试添加 - 请按照
到 git log
调用,文件在目录中移动并更改名称,所以 git show
调用失败在路径上的变化。我尝试插入各种东西来抓取完整路径( fullname =`ls-tree --name-only $ f - filename`
等)并传递它到 git show
,但没有任何工作,我没有找到谷歌和SO搜索很多。我觉得我错过了一些显而易见的东西,比如 git log --format
trick。
我会也可以接受获取文件所有完整路径的名称,以及获取不再存在路径的完整历史记录的方法。然后,我可以分阶段,虽然我更喜欢一次性的方法。
我管理用这个提取出我需要的数据: `git log --follow --format ='%h' - name-only - 文件名| vim -`
信息像Vim一样进入:
21acc7c
工作/旧名称
dea4a67
工作/文件名称
103b0ee
工作/子文件夹/文件名
387b384
工作/文件名
741bbc7
文件名
等..
我做了:g / filename / norm kkJJ
21acc7c工作/旧名称
dea4a67工作/文件名称
103b0ee工作/子文件夹/文件名
387b384工作/文件名
741bbc7文件名
我把所有东西都换成了我所需要的东西,尽管我不得不跳过一些环节来排序,因为git只能存储到第二个,并且rebase往往会在同一时间创建很多提交。父母保持订单,但这意味着我必须处理循环中的订单,而不是基于任何类似于 git show
或 git log
info。
I can do this just fine:
git log --format=%h -- filename | while read f; do git show $f:filename; done
However, if I try to add --follow
to the git log
call, the file moves through directories and changes names, so the git show
call fails on the path change. I've tried inserting various things to grab the full path (fullname=`ls-tree --name-only $f -- filename`
, etc.) and passing it on to git show
, but nothing's working, and I'm not finding much with google and SO searches. I feel like I'm missing something obvious, like a git log --format
trick.
I'd also accept just getting all the full path names the file has ever been, and a way to get the full history of no-longer existing paths. Then I could take this in stages, though of course I'd prefer the all-at-once approach.
I managed to pull out the data I need with this:
`git log --follow --format='%h' --name-only -- filename | vim -`
Information came in like this to Vim:
21acc7c
work/oldname
dea4a67
work/filename
103b0ee
work/subfolder/filename
387b384
work/filename
741bbc7
filename
etc...
I did :g/filename/norm kkJJ
to join them into this:
21acc7c work/oldname
dea4a67 work/filename
103b0ee work/subfolder/filename
387b384 work/filename
741bbc7 filename
This let me regex things into what I needed, though I had to jump through some hoops to keep things sorted, as git only stores down to the second, and rebases tend to create many commits at exactly the same time. The parenting keeps the order, but it meant that I had to deal with ordering in the looping, and not based on anything like git show
or git log
info.
这篇关于如何通过重命名来追踪文件的修订版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!