如何从'git filter-branch'获取旧>新重写的提交SHA列表? [英] How do I get a list of old->new rewritten commit SHAs from 'git filter-branch'?

查看:100
本文介绍了如何从'git filter-branch'获取旧>新重写的提交SHA列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行 git filter-branch 后,如何获得由filter-branch重写的新提交SHA的旧提交SHA列表?



例如,类似于以下内容:

  b19fd985746c1f060f761d42d353e387bec243fb  - > c8ab40ef9bae3b58642a8d1e5b90720d093a60b5 
c5ebba1eeb92ca76c0effa32de14178ec7f07db6 - > 4d5a9958b98dbcfa47ce1354bb2af4cc77904639
705f71543235b872ca3e1067538e36d14044429d - > d2aafbd6e5b91955b62dee34f4a0abf0171ba016

其中左列是原始SHA列表,右列是新的SHA之后被过滤器分支重写。



我看到页面提到了一个 map 函数,但我不明白这在这里是否有用,或者如果是的话,如何使用它。



感谢您的帮助!

解决方案

我不得不围绕 git-filter-branch 的源代码来解决这个问题。它没有记录(据我所知),但旧的提交ID显式导出为 $ GIT_COMMIT 。这工作对我来说:

$ $ p $ $ git过滤器分支 - 您的过滤器在这里--commit过滤器'回声-n $ {GIT_COMMIT},>> / tmp / log; git commit-tree$ @|三通-a / tmp目录/日志你的分支,这里
[...]
$猫的/ tmp /日志
70d609ba7bc58bb196a2351ba26afc5db0964ca6,d9071b49743701c7be971f76ddc84e76554516c7
0d1146dcabc00c45fb9be7fe923c955f7b6deb50,cb6813f9aca5e5f26fcc85007c5bb71552b91017
[...]

(该文件的格式 < original commit hash>,< new commit hash> 。)

虽然。如果您使用的是过滤分支正确的方式(即不操纵现有已发布的历史记录),那么您不需要知道哪些信息。


After running git filter-branch, how do I get a list of old commit SHAs as rewritten by filter-branch to their new corresponding commit SHAs?

For example, something similar to:

b19fd985746c1f060f761d42d353e387bec243fb -> c8ab40ef9bae3b58642a8d1e5b90720d093a60b5
c5ebba1eeb92ca76c0effa32de14178ec7f07db6 -> 4d5a9958b98dbcfa47ce1354bb2af4cc77904639
705f71543235b872ca3e1067538e36d14044429d -> d2aafbd6e5b91955b62dee34f4a0abf0171ba016

Where the left column is the list of original SHAs, and the right column are the new SHAs after being rewritten by filter-branch.

I see that the man page for filter-branch mentions a map function, but I don't understand whether that's useful here, or if it is, how to use it.

Thanks for your help!

解决方案

I had to go poking around the source for git-filter-branch to work this one out. It's not documented (as far as I can tell), but the old commit ID is explicitly exported as $GIT_COMMIT. This worked for me:

$ git filter-branch --your-filters-here --commit-filter 'echo -n "${GIT_COMMIT}," >>/tmp/log; git commit-tree "$@" | tee -a /tmp/log' your-branch-here
[...]
$ cat /tmp/log
70d609ba7bc58bb196a2351ba26afc5db0964ca6,d9071b49743701c7be971f76ddc84e76554516c7
0d1146dcabc00c45fb9be7fe923c955f7b6deb50,cb6813f9aca5e5f26fcc85007c5bb71552b91017
[...]

(That file, of course, has the format <original commit hash>,<new commit hash>.)

I'm kind of curious what your intentions are with using this though. It doesn't seem like information you'd need to typically know if you're using filter-branch the "right" way (i.e., not manipulating existing published history).

这篇关于如何从'git filter-branch'获取旧&gt;新重写的提交SHA列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆