I want to get a list of all the branches in a Git repository with the "freshest" branches at the top, where the "freshest" branch is the one that's been committed to most recently (and is, therefore, more likely to be one I want to pay attention to).
(我想得到一个Git存储库中所有分支的列表,顶部有“最新鲜”的分支,其中“最新鲜”的分支是最近提交的分支(因此,更可能是一个分支)我想要注意)。)
Is there a way I can use Git to either (a) sort the list of branches by latest commit, or (b) get a list of branches together with each one's last-commit date, in some kind of machine-readable format?
(有没有办法可以使用Git(a)通过最新提交对分支列表进行排序,或者(b)以某种机器可读格式获取分支列表以及每个分支的最后提交日期?)
Worst case, I could always run git branch
to get a list of all the branches, parse its output, and then git log -n 1 branchname --format=format:%ci
for each one, to get each branch's commit date.
(最糟糕的情况是,我总是可以运行git branch
来获取所有分支的列表,解析其输出,然后git log -n 1 branchname --format=format:%ci
为每个分支,以获得每个分支的提交日期。)
But this will run on a Windows box, where spinning up a new process is relatively expensive, so launching the Git executable once per branch could get slow if there are a lot of branches. (但是这将在Windows机器上运行,其中启动新进程相对昂贵,因此如果有很多分支,每个分支启动Git可执行文件可能会变慢。)
Is there a way to do all this with a single command? (有没有办法用一个命令完成所有这些?)
ask by Joe White translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…