获取所有git commit的列表,包括“丢失的"提交 [英] Get a list of all git commits, including the 'lost' ones

查看:49
本文介绍了获取所有git commit的列表,包括“丢失的"提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我有一个这样的图:

Let's say that I have a graph like this:

A---B---C---D (master)
     \
      \-E---F (HEAD)

如果我执行 git log --all --oneline ,我将得到所有六个提交.

If I do git log --all --oneline, I will get all six of my commits.

但是如果图形是

A---B---C---D (master, HEAD)
     \
      \-E---F

我看不到E和F.我可以让git告诉我所有提交,包括那些未命名的分支吗?

I will not see E and F. Can I get git to tell me all the commits, including those on branches which are not named?

谢谢

推荐答案

并不是特别容易-如果您丢失了指向分支尖端的指针,那就像在大海捞针中找针.您可以找到所有似乎不再被引用的提交- git fsck --unreachable 将为您完成此操作-但这将包括您在 git之后扔掉的提交commit --amend ,您重新建立了分支的分支上的旧提交等.因此,一次看到所有这些提交很可能会浪费太多信息.

Not particularly easily- if you've lost the pointer to the tip of a branch, it's rather like finding a needle in a haystack. You can find all the commits that don't appear to be referenced any more- git fsck --unreachable will do this for you- but that will include commits that you threw away after a git commit --amend, old commits on branches that you rebased etc etc. So seeing all these commits at once is quite likely far too much information to wade through.

因此,简单的答案是,不要跟踪您感兴趣的事物.更严重的是,默认情况下,刷新日志将保留对您最近60天内使用过的所有提交的引用.更重要的是,他们将提供有关那些的内容的背景信息.

So the flippant answer is, don't lose track of things you're interested in. More seriously, the reflogs will hold references to all the commits you've used for the last 60 days or so by default. More importantly, they will give some context about what those commits are.

这篇关于获取所有git commit的列表,包括“丢失的"提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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