[英]How to show git log history in reverse order at the Android Studio?
[英]How to git log in reverse order?
我最近了解到,我可以使用 hg log 以相反的順序打印歷史記錄:
hg log -r :
所以我當然嘗試了:
git log -r :
好吧,它沒有用。 那么在 git 中做同樣事情的命令是什么?
使用--reverse
選項:
git log --reverse
您不需要一直鍵入--reverse
,也不需要 bash 函數。 您可以只創建一個 git 別名。 打開你最喜歡的文本編輯器並打開你的全局.gitconfig
文件。 它通常位於您的主目錄中。
導航到或創建這樣的部分:
[alias]
lg = log -10 --reverse
這將創建一個 git 別名,該別名獲取最近的 10 個提交,然后反轉該列表,因此這 10 個中的最新提交位於底部。 現在您可以簡單地運行:
混帳
Jakub Narębski的評論(“請注意,例如git log -10 --reverse
將獲得 10 次最后提交然后反向列表”)已在 Git 2.11(2016 年第四季度)中得到澄清:
請參閱Pranit Bauva ( pranitbauva1997
)的提交 04be694 (2016 年 9 月 27 日)。
(由Junio C Hamano -- gitster
--在提交 54a9f14中合並,2016 年 10 月 11 日)
rev-list-options
:闡明--reverse
的用法用戶經常想知道最舊的或最新的
n
次提交是否由log -n --reverse
。
澄清--reverse
僅在決定要顯示哪些提交以使它們混淆之后才起作用。
請參閱提交限制。
以上都不起作用...除了這個最近提交消息+統計信息
git log --graph --stat
更多片段〜/ .gitconfig:
lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"
lg3 = log -10 --reverse --abbrev-commit
您可以創建一個 bashrc 函數(假設您使用的是 unixy 操作系統)
function git_logr {
git log --reverse
}
我將幾個建議的內容合二為一,並創建了一個別名。
git log -10 --pretty=oneline --abbrev-commit --reverse
alias gl='git log -10 --pretty=oneline --abbrev-commit --reverse'
如果你想要一個顛倒順序的git --graph
,你不能使用--reverse
不幸的是,但你可以使用tac
:
git log --graph --color | tac
請注意, --color
在這里很重要。
作為 git 別名:
git config --global alias.logr '!git log --graph --color | tac'
(然后當然將您喜歡的標志添加到git log --graph
;)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.