Git error: Your local changes to the following files would be overwritten by checkout

When you get the Git checkout error, “Your local changes to the following files would be overwritten by checkout,” one likely cause is that files in the master branch are indeed newer than the files in your feature branch.

But another possibility that I just learned about is that you did a git add, but forgot to do a git commit before trying to switch branches. My current wrong/accidental workflow looks like this:

How-to: Steps to create a Github pull request

I haven’t worked on many open source projects, so my ability to fork a Github project, pull it down, create a branch, push that branch back, and then submit a pull request are weak, at best.

That being said, I’ve done it a few times lately, so I’m getting better at it. Today was a very smooth process, so I thought I’d make these notes while they’re still fresh in my mind.

The Git “topic branch” workflow (pattern)

In this short article, I’ll demonstrate the typical workflow for using a Git topic branch. If you’ve never heard of a topic branch, here’s a description from the excellent book, Pro Git:

“A topic branch is a short-lived branch that you create and use for a single particular feature or related work.

git status message - Your branch is ahead of origin/master by X commits

git status FAQ: When I issue the "git status" command, I see the following "Your branch is ahead or origin/master ..." git message:

# On branch master
# Your branch is ahead of 'origin/master' by 5 commits.
nothing to commit (working directory clean)

What does this "Your branch is ahead of 'origin/master' by X commits" message mean? I keep committing my changes with "git commit", so this message seems to be in error.

Git shortcuts/aliases - How to create

Git shortcuts FAQ: Can I create Git shortcuts (aliases) so I don't have to type out full Git commands like "git commit..."?

I've been reading the Pro Git book a lot lately, and the short answer is yes, you can create Git shortcuts so you don't have to type out the long Git commands. Here are several Git shortcut commands (referred to as "git aliases") from the Pro Git book: