AidanMontareDotNet

You are on the old part of aidanmontare.net, which I am no longer maintaining. Newer versions of some of this content can be found on the active part of my site, which you can reach from my homepage.

Git Reference

(last updated

Git is pretty awesome. However, forgetting how to use all this awesomeness is not awesome. To try to keep the git as awesome as possible, I have collected here a list of commands and notes about using Git.

This is not intended to be a definitive guide to Git, nor is it a good introduction to using Git. However, it is a useful time saver for those who occasionally use Git, but often forget command syntax.

Setting Things Up

Git Config

Make sure to do these before you get started committing!

$ git config [options] user.name "[name]"
Set the name that appears when you commit to the project.

$ git config [options] user.email "[email]"
Set the email that appears when you commit to the project.

Useful Options

--global sets the value in ~./gitconfig (applies to all projects current user)
--system sets the value in a system-wide location (applies to all users on the system)

Starting a Project

$ git init [name]
Initialize a new project in the current directory.

git clone [url] [directory]
Initialize a new project into [directory] by cloning an existing project.

Making Commits

git add [path]
adds files at [path] to the commit

git add -A [path]
adds and removes files at [path] to update the index

Branching

Creating

Merging

Rebasing

[when not to use]

Finishing

Undoing Changes

A generally helpful guide on undoing things.

Fast-Forward Merges

A merge where you simply move one pointer forward along the commits, which results in no separate merge commit. If you accidentally merge the wrong branch and this happens, you might be confused when there is no merge commit to undo. Here is a useful discussion on how to fix these kinds of errors.

Changes to the Working Directory

A good discussion of some options.

Fixing Things That Break

https://stackoverflow.com/questions/11706215/how-to-fix-git-error-object-file-is-empty

Customizing Git

Filetype Support

.docx files

docx files appear by default as binary files to Git. However, you can configure a rudimentary docx-to-txt converter that will allow Git to show you changes to these files.

This solution isn’t great (you can’t track formatting changes), but it is useful enough if you should happen to have .docx files within a project.

The instructions are well written here, so I won’t repeat them here.

Further Reading

Locations where I learned a lot of this stuff.