Git Miscellany



A bunch of things about Git

My First Attempt at Understanding Git    

Take a look at my Overview of Git States and Transitions article

Git How-Tos    

Here's a bunch of things that I struggle to remember, or have struggled to remember in the past. Putting them here saves me from googling the same thing repeatedly.

How to Delete a Branch Both Locally and at the Remote    

For example:

git push --delete remote_name branch_name
git branch -d branch_name

## Or if branch isn't merged:
git branch -D branch_name

How to Remove Obsolete Remote-Tracking Branches    

git fetch -p

How to Fix a Messed Up Commit Order    

I've sometimes had strange commit orders in my GitHub pull requests. This happens after reordering commits (eg using an interactive rebase).

Here are some ways to get the commits to be in a sensible order:

  • You can by using reword instead of pick when doing the rebase.

  • (I haven't tried this yet.) Apparently git rebase –committer-date-is-author-date will work if you have a non-buggy Git version.

(Git commits have both an author date and a committer date. I guess that when you pick a commit, the author date does not get changed.)