Getting Started with Git

I don't know about you, but using Git, especially from the command line, has always been intimidating. At least until recently.

I've known for awhile now the importance of source control for your projects and so I've been doing my best to use it. Thanks to the awesome GitHub applications I was able to at least get started with the comfort of a GUI. But anytime someone mentioned "branches", "pull requests", "merges", "upstream", and countless other terms, I panicked. I stayed with my basic commits on master branch, hoping I didn't screw something up and afraid I would if I tried any of these other commands.

Then I took the awesome "How to Use Git and Github" course over at Udacity. I love Udacity's courses, but this one has already been one of the most useful courses I've taken. If you're scared to use version control like I was, you should definitely check this class out.

I also came across this helpful Git repo this morning, "Git Style Guide". If you're looking for next steps this seems to be an awesome place to look, especially when working with others.

You should definitely check those resources out, but I also wanted to share three things I've learned when using Git:

1. Branches are your Friend

A good chunk of the projects I work on I am the only contributor, so I've gotten by okay with only a master branch. Aside from the obvious benefits of working with others, I am beginning to see the value of using branches on personal projects.

Branches allow you to experiment without causing issues with production-ready code. You can make big fixes to a working version without having to release your experiment. And, more importantly, if the experiment doesn't work out you can get rid of the branch without having to mess with all your commit history.

2. Commit based on Logical Changes

This is a huge lesson for me. Too often I get going, make a bunch of changes, forget to commit for awhile, and then just lump it all together in one big commit.

This is okay, but if I ever need to roll changes back, it will make my life a lot easier if I can tell what each commit contributed to the code. This will take a little more discipline in committing more often and thinking through why I am adding each file to my commit. But it will save my sanity (and memory) as I move forward on the project.

3. Practice using the Command Line

Taking the Udacity class forced me to practice using the command line, something I had been avoiding for far too long. Don't get me wrong, there is a lot you can do in some of the applications out there, and there are some tasks I will still use them for.

But the speed at which I am able to work and the extra features I am able to access from the command line are invaluable. It does take some practice to get them all in your memory, so open up your shell and get practicing. If you are in need of a cheat sheet, GitHub has a great one.

So what do you think? Are you going to give Git another try? Do you have any other tips to share? Let me know!