I can't even count how many times I run
git branch during an average workday. With multiple tickets assigned to me across multiple projects, keeping track of exactly where I am in our codebase can be a real challenge -- especially in my case, where my short-term memory is affected by ADHD. But with just a few extra lines added to
.bashrc, my current branch info is now right in my Bash prompt!
- At the bottom of the file, add the following:
export GIT_PS1_SHOWDIRTYSTATE='y' export GIT_PS1_SHOWSTASHSTATE='y' export GIT_PS1_SHOWUNTRACKEDFILES='y' export GIT_PS1_DESCRIBE_STYLE='contains' export GIT_PS1_SHOWUPSTREAM='auto' export PS1='\[\033[32m\]\u@\h\[\033[00m\]:\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$
Save your changes and exit.
You may need to close and reopen your Bash prompt before the changes show up, but from now on, whenever you're in a local repo, you'll see the name of the current branch and its status right there on the command line.
=: Local branch is up to date with the remote version
*: Updated files need to be staged
+: Staged files need to be committed
>: Local branch is ahead of remote branch --
<: Remote branch is ahead of local branch --
<>: Remote and local branches are in conflict or otherwise diverged