Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autorefresh git log after commit when running in the Terminal

Tags:

git

git-log

Is it possible git log to be auto refreshed after commit or can I use another utillity in the Terminal to see list of all previous commits which auto refreshes itself?

like image 630
cerruti Avatar asked Aug 23 '11 06:08

cerruti


People also ask

Which is used to show commit logs in git?

The git log command displays all of the commits in a repository's history. By default, the command displays each commit's: Secure Hash Algorithm (SHA)

How can I see my git command history?

`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.

How do I limit a git log?

We can limit the git log output by including the -<n> option. This enables us to specify how many log messages are printed in the terminal. We can add the --oneline flag to show each commit on one line.


2 Answers

I prefer the following, because it's cleaner than the other solution:

watch git log -2

Much easier to type

If you want to refresh each 5 seconds, instead of 2 seconds, use

watch -n 5 git log -2

For those without watch function/binary:

function watch()
{
    local delay=2
    local lines=$(tput lines)
    lines=$((${lines:-25} - 1))

    if [[ "$1" -eq "-n" ]]; then
        shift 
        delay=$((${1:-2}))
        shift 
    fi

    while true
    do
            clear
        "$@" | head -n $lines
        sleep $delay
    done
}
like image 191
sehe Avatar answered Nov 11 '22 16:11

sehe


You mean something like this?

 while true; do clear; git log -2 | cat; sleep 5; done

This shows the top two git log entries, refreshing every 5 seconds. The "| cat" is there to avoid git opening a pager.

This does not get new remote changes, though.

like image 40
daniel kullmann Avatar answered Nov 11 '22 17:11

daniel kullmann