Using Git

Last modified: Aug 4th, 2020

The ability to use version control properly is a skill every software developer needs. Personally I have only used Git.

Getting Started

There are some great resources available on the web to get started with Git:

Interfacing with git

By default you can interface with Git through the command line, which is how I started out using Git. I learned that there are several visual interfaces available but they never allowed me to do what I wanted as quickly as I could using the cli (with some exceptions). This might have been a result of learning to use the cli first though.

If you are interested in a visual interface for git take a look at your preferred editor as it might already have some sort of interface for Version Control. If it doesn’t take a look here for a list of GUI’s.

Magit open for this repository

Since the beginning of this year (2020) I’ve started using Emacs which allows you to install an awesome package named Magit. This package allowed me to use git:

  • faster (through keybindings),
  • without the need to remember commands or their parameters, and
  • more intuitively by visualising the changes.

If you are using Emacs I highly recommend you to check this package out.

Tips & Tricks

User Configuration

After installing git you should always perform these steps to properly configure the tool.

# Set your identity
git config --global "John Doe"
git config --global

# Set your preferred editor
git config --globar core.editor emacs

# Review your settings
git config --list

Ignoring files globally.

MacOS stores custom attributes for a folder inside it through a .DS_Store file. This includes personal attributes and therefore does not need to be shared in most git projects. As this is OS specific I include it in my global .gitignore instead of placing it in every .gitignore for each project.

# Setup your global .gitignore
touch ~/.gitignore

# Make sure we ignore any .DS_Store file in our git projects.
# This can also be done using your editor of choice.
echo '.DS_Store' >> ~/.gitignore

# Tell git about your global .gitignore file.
git config --global core.excludesfile '~/.gitignore'

If you like my work you can reach out to me on twitter (@nickbelzer) or buy me a coffee. You can find the source code for both the site and it's content on Github.