The default installation of git leaves you with a fairly spartan
interface. These are some of my tips for making it more pleasant to
use. On Windows, this is accessed through
git bash, and on Mac,
accessed through the terminal.
Obviously, you need git installed. Check to see you have it installed
git --version, which will produce output like this:
If not, install git first!
The first thing is to set your name and email. These will appear all over the place, so they are good to set up first. It feels a bit weird if you’re the only person using a reposirory, but you only have to set this once. So run
These are global options and will affect all repositories. These
can actually be over-ridden on a per-repository basis, but you don’t
generally need to do that. The configuration options go into the file
~ means “home” in unix commands).
The default editor is
vi – if you have used this
before, this will probably be fine, but if not you are in for a rude
shock. So, next, let’s set that to be a better option.
On a Mac
First, check that you have
nano installed by typing
and then running
(but change the path to reflect where it is installed. In most
situations it will be
Whenever git needs you to write a message on a commit, it will pop
nano. Write the message and quit with
Control-X (X for
exit), answering “Y” when prompted to save the file.
--tempfile option will cause
nano to save on exit
without prompting or asking about the filename. This can be nice to
avoid being bothered the whole time.
However, it removes the ability to easily abort a commit by not saving the message.
On a Mac, it is possible to use something like “TextEdit” to edit the file, by running
There is a catch though; you have to make sure that you quit the
application after writing your message. The
-n option means that
this is new instance of TextEdit so you won’t lose other open work
when doing this at least.
The simplest solution is to set
which will use notepad. Notepad makes a bit of a mess of the files when you edit them, but will be good enough to get you going. Longer term, you may find something like using notepad++ more enjoyable, but setting this up is a bit of a hassle.
By default (on Mac and Linux at least), the command line is fairly stark, but git has options to spruce it up with nice colours. More than just look pretty, these allow you to much more easily scan output.
and the output of
diff (and a few others) will be
coloured for you.