I’ve been using Git at work for around 10 years now. I started using Git with a GUI (Tower — back when I was eligible for the student discount!), but now I use the CLI for everything except complicated diffs and merges, where I use Kaleidoscope.
A question I get asked by my coworkers often is: “how in the world do you manage using Git without a GUI?”. This blog post is supposed to answer this question.
First, I use the Fish shell. It fits with the way I think. A lot of you probably use bash
or zsh
, that’s fine, there is lots of documentation on how to integrate Git with those shells. This is the relevant part of .config/fish/config.fish
:
set __fish_git_prompt_show_informative_status 'yes' set __fish_git_prompt_color_branch magenta set __fish_git_prompt_color_cleanstate green set __fish_git_prompt_color_stagedstate red set __fish_git_prompt_color_invalidstate red set __fish_git_prompt_color_untrackedfiles cyan set __fish_git_prompt_color_dirtystate blue function fish_prompt # ... set_color normal printf ' %s' (prompt_pwd) printf '%s' (__fish_git_prompt) printf ' > ' end
I’ve omitted the irrelevant portions (status checking, #
prompt when root, etc. If you want to see the full file, I’ve posted it as a gist.
On a clean working directory (that is, no changed files that haven’t been committed to the repository), this looks like this:
When updating some files, it will change to something like this:
This prompt doesn’t change in real time, so changes from other terminals won’t automatically change this prompt. I have a habit of tapping the “return” key to update the prompt.
To commit these changes:
The commands I use most often:
git add
(if you only want to add a portion of a file,git add -p
is your friend) /git commit
git push
/git pull
(git pull --rebase
for feature branches being shared with other devs)git diff @
— show all changes, staged or not, between the working directory and the latest commit of the branch you are on (@
is a alias forHEAD
)git diff --cached
— show only changes that are being staged for the next commitgit status
git difftool
/git mergetool
(this will open Kaleidoscope)
This was obviously a very cursory, high-level look at how I use Git, but I hope it was useful. It’s been a long time since I’ve used a Git GUI full time, but whenever I do use one (for example, when helping a coworker), it feels clunky compared to using the CLI (that’s not saying I don’t have my complaints about the CLI — that’s another blog post 😇).
If you have any more questions, leave a comment or contact me on Twitter, and I’ll update this post with the answers.