Month: November 2014

Git Basics Part 3

So far, In my git tutorials, I’ve talked mostly about version control on your own machine. With this last tutorial we will be moving to Github to store and keep a backup of any git repository you have. Github has some amazing tutorials to guide you through putting your git repository on Github, so they are a great resource if you are ever confused about Github or even git in general.

The first step in using Github is to create a Github account and a repository. Once you have your repository set up, you can go ahead with the default settings. Leave ‘Add a readme’ unchecked, if you already have a git repository on your machine. Once your repository is created, you should be able to find a link in this box, pictured below.

Copy that link, and paste it into this git command to link up your repository and the repository on Github.

onionchesse@hunger:$ git remote add origin <Github URL>

Leave the angle brackets out when copying in the url! If that goes successfully, you now have linked your git repository with the one on Github! You can issue a ‘git push’ to upload a change to Github. If you decide to make a change online, such as through the Github web UI, you can bring those changes into your repository on your computer with the ‘git pull’ command! It really is that simple. But yet, it isn’t.

The reality is that git is an easy to use program with very hard to use features embedded inside of it. Branches, Pull Requests, Rebases, and Merges are all advanced features that you should understand before actually attempting. You already did a great favor for yourself by learning the command line interface, which is really the only true way to learn git internals, to actually understand what it is doing. The first time you get a ‘merge’ conflict can be a frightening one, but that simply means that git wasn’t able to combine two commits (one from online, and one from your computer) without overwriting code! There are many tools online for fixing merge conflicts.

All in all, I wish you good luck with git, but with these guides, you should be well set off with the basics of git, enough to manage your own files from time to time! Take care, and don’t forget to commit!

– [onion] chesse