How to make git-log scroll up instead of down

前端 未结 4 1318
时光取名叫无心
时光取名叫无心 2021-01-13 02:51

Whenever I view a git log --all --graph --oneline --decorate output in my terminal emulator, the first commit is viewed at the top of the terminal screen. When

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-13 03:09

    A command that comes close to the intended result is

    git --no-pager log --all --graph --decorate --oneline --color=always | tac | less -r +G -X
    

    However, this still messes up the graph a little bit, as the slashes are not reversed properly.

    Update

    This command takes also care of swapping the slashes with backslashes and vice versa.

    git --no-pager log --all --graph --decorate --oneline --color=always | tac | sed -e 's/[\]/aaaaaaaaaa/g' -e 's/[/]/\\/g' -e 's/aaaaaaaaaa/\//g' | less -r +G -X
    

    The corresponding git alias is

    [alias]
        rlog = !"git --no-pager log --all --graph --decorate --oneline --color=always | tac | sed -e 's/[\\]/aaaaaaaaaa/g' -e 's/[/]/\\\\\\\\/g' -e 's/aaaaaaaaaa/\\\\//g' | less -r +G -X"
    

提交回复
热议问题