.bash_profile

Git bash: Clear screen and show diff

I just added another little convenience command for Git Bash. This is for clearing the screen and showing the diff (changes) in your branch. I added support for a parameter so you can use it either to show all differences, show the changes for a specific file, or append some other parameter to it (see the examples below).

Here`s the code itself – append it to your .bash_profile file, then restart your git bash:

cdiff(){
    clear
    if [ "$1" ]; then
        git diff "${1}"
    else
        git diff
    fi
}

Examples of usage:

cdiff # Will clear screen and show all changes not added

cdiff --cached # Will clear screen and show changes in added files

cdiff my-file.xyz # Wil clear and show changes for the specified file

cdiff --name-only # Will clear, then list all changed files (not added)