git status --porcelain=v2 --branch
)There are four different implementations with identical output:
Compiling the Go version::
go build git-prompt.go
Then copy git-prompt
to somewhere in your path and add this to the
PS1
variable in your .bashrc
/ .zsh
or other config file:
$(git-prompt)
Here's what I use:
PS1='\u@\h:\w $(git-prompt)> '
[main] # At main branch with clean repository.
[main *] # Uncommited changes.
[main ↑] # One or more commits ahead of remote.
[main *?] # Changes and untracked files.
[main *!] # Unmerged conflict.
[:initial] # New git repository with no commits yet.
main Branch name.
:f9a02c Detached head. (First 6 characters of commit hash.)
:initial Initialized repository with nothing commited yet.
* Repository has uncommited changes.
? There are untracked files.
! There are conflicts.
↑ Local repository is ahead of remote by >= 1 commit.
↓ Local repository is behind remote by >= 1 commit.
↕ Local repository has diverged from remote.
(It's both ahead and behind.)
Green : Working directory is clean but may be out of sync with remote.
Yellow : There are changed or untracked files.
Red : There are conflicts that need to be resolved.
Ole Martin Bjorndalen - ombdalen@gmail.com