Way to show merging status in command line in git
bash, command-line, git
Solution
You can see in this git-ps1 script a much more complete status indicator, with rebase and merge in it.
local g="$(git rev-parse --git-dir 2>/dev/null)"
if [ -n "$g" ]; then
local r
local b
if [ -d "$g/rebase-apply" ]
then
if test -f "$g/rebase-apply/rebasing"
then
r="|REBASE"
elif test -f "$g/rebase-apply/applying"
then
r="|AM"
else
r="|AM/REBASE"
fi
b="$(git symbolic-ref HEAD 2>/dev/null)"
elif [ -f "$g/rebase-merge/interactive" ]
then
r="|REBASE-i"
b="$(cat "$g/rebase-merge/head-name")"
elif [ -d "$g/rebase-merge" ]
then
r="|REBASE-m"
b="$(cat "$g/rebase-merge/head-name")"
elif [ -f "$g/MERGE_HEAD" ]
then
r="|MERGING"
b="$(git symbolic-ref HEAD 2>/dev/null)"
For the merge part, it does indeed test for `MERGE_HEAD` file, as suggested by Zeeker.
Problem
I currently have git configured to show which branch I am on, (and my command line to show which directory I am on) with the following bash script: ``` export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\] \[\033[33;1m\]\w\[\033[m\] (\$(git branch 2>/dev/null | grep '^*' | colrm 1 2)) \$ \n$ " export PS2="$ " ``` I am wondering if there is a way to show show the "merging" status, so that when I am merging it also says `merging` in the command line (after which branch I am on). I have seen this elsewhere so I am pretty sure it is possible but do not know how.