How to git log in reverse order?

前端 未结 5 1373
借酒劲吻你
借酒劲吻你 2021-01-30 05:43

I recently learned that I can get hg log to print the history in reverse order with:

hg log -r :

So of course I tried:

git log          


        
相关标签:
5条回答
  • 2021-01-30 06:19

    You could create a bashrc function (assuming you are on a unixy os)

    function git_logr {
    
        git log --reverse
    
    }
    
    0 讨论(0)
  • 2021-01-30 06:21

    Use the --reverse option:

    git log --reverse
    
    0 讨论(0)
  • 2021-01-30 06:26

    I combined few of suggested one into one and I created an alias.

    git log -10 --pretty=oneline --abbrev-commit --reverse
    
    alias gl='git log -10 --pretty=oneline --abbrev-commit --reverse'
    
    0 讨论(0)
  • 2021-01-30 06:28

    You don't need to type --reverse all the time, nor do you need a bash function. You can just create a git alias. Open up your favorite text editor and open up your global .gitconfig file. It's usually found in your home directory.

    Navigate to or create a section like this:

    [alias]
        lg = log -10 --reverse
    

    That creates a git alias that grabs the ten most recent commits then reverses that list so the most recent of those 10 is at the bottom. Now you can simply run:

    git lg

    0 讨论(0)
  • 2021-01-30 06:39

    Jakub Narębski's comment ("Note that e.g. git log -10 --reverse would get 10 last commits then reverse list") has been clarified in Git 2.11 (Q4 2016):

    See commit 04be694 (27 Sep 2016) by Pranit Bauva (pranitbauva1997).
    (Merged by Junio C Hamano -- gitster -- in commit 54a9f14, 11 Oct 2016)

    rev-list-options: clarify the usage of --reverse

    Users often wonder if the oldest or the newest n commits are shown by log -n --reverse.
    Clarify that --reverse kicks in only after deciding which commits are to be shown to unconfuse them.

    See Commit Limiting.

    0 讨论(0)
提交回复
热议问题