有没有办法找出一个提交来自哪个分支给它的sha1?
如果您能告诉我如何使用Ruby Grit完成此任务,那么奖励积分.
我创建了新的分支master:
git checkout -b testbranch
我做了20次提交.
现在我要压缩那20个提交.我这样做:
git rebase -i HEAD~20
如果我不知道有多少提交怎么办?有什么方法可以做以下事情:
git rebase -i all on this branch
我想列出仅属于特定分支的所有提交.
通过以下内容,它列出了分支中的所有提交,但也列出了父(主)的提交
git log mybranch
Run Code Online (Sandbox Code Playgroud)
我找到的另一个选项是排除master可以访问的提交并给我我想要的东西,但我想避免需要知道其他分支名称.
git log mybranch --not master
Run Code Online (Sandbox Code Playgroud)
我试图使用git for-each-ref,但它也列出了mybranch所以实际上它排除了所有:
git log mybranch --not $(git for-each-ref --format '^%(refname:short)' refs/heads/)
Run Code Online (Sandbox Code Playgroud)
更新:
我正在测试我刚才发现的一个新选项,直到现在看来这可能是我想要的:
git log --walk-reflogs mybranch
Run Code Online (Sandbox Code Playgroud)
更新(2013-02-13T15:08):
--walk-reflogs选项很好,但我检查了reflogs是否到期(默认为90天,gc.reflogExpire).
我想我找到了我想要的答案:
git log mybranch --not $(git for-each-ref --format='%(refname)' refs/heads/ | grep -v "refs/heads/mybranch")
Run Code Online (Sandbox Code Playgroud)
我只是从可用分支列表中删除当前分支,并使用该列表从日志中排除.这样我只能获得mybranch才能达到的提交.