Forgit About It

WARNING: may contain bad Git puns

Git Commands I End Up Googling

I am a dedicated fan of Git for version control; however, I inevitably find myself googling how to do something with Git, especially if it’s been a while. I’ve compiled a few of the Git commands and concepts that I’ve found myself searching for recently while in the midst of writing code.

So, in no particular order:

git merge --no-commit --no-ff yourbranchname

This command allows you to do a “practice run” of a merge action. You’d probably want to follow with git diff.

git rm -r --cached yourdirectory

This command (followed by a git commit and git push) allows you to remove a directory from the remote. In the past, I’ve added a previously included directory to the .gitignore and then realized that the directory wasn’t automatically removed from the remote. This’ll fix that!

git remote set-url origin https://yourawesomerepo.git

I often forget the exact syntax for this one (usually omitting the set-url part)! This command allows you to point your local copy of the repo at a different remote URL. Occasionally, I’ll create a repository and end up needing to change the repo name, transfer ownership of the repo on GitHub, or have another need to add or change the remote URL. Note: it doesn’t have to be origin. It could be some other remote type…this is just the most common for my usage.

Finally, I feel obligated to mention Gitflow, a set of Git extensions based on Vincent Driessen’s Git branching model of the same name.

It is an excellent resource and I highly recommend incorporating it into your development process if you tend to write code in a collaborative manner. Even if you don’t, it can be handy if you use and merge branches for your work. The Gitflow extensions abstract away some of the more complicated Git workflows and enable the use of a few concise, understandable commands instead. These commands handle common branching and merging flows that you might leverage to develop and publish hotfixes, features, and releases.

Now you know about my most-googled Git commands :)

This is Git. It tracks collaborative work on projects through a beautiful distributed graph theory tree model.  Cool. How do we use it? No idea. Just memorize these shell commands and type them to sync up. If you get errors, save your work elsewhere, delete the project, and download a fresh copy.

This XKCD basically sums it up.