Instructables

Introduction to GitHub

Picture of Introduction to GitHub

I've been using people's code from GitHub for a couple of years and without it, I'd be totally stuck in my various projects. I want to give back.

I had a mixture of confusion and laziness around how GitHub works, which got in my way. I eventually figured it out, but it took some bumping around.

This Instructable will explain the basics of creating a Git repository, how it works and how to upload it onto GitHub.

I'll be using the commands from the Terminal application on the Mac, but the principles can be extended to other platforms as well.

What is Git vs. GitHub?
Git is a source code version control system, which a series of "commits" or snapshots of your code. You make the commits manually.

GitHub is a website (github.com) where you can publish your Git repositories for public download and possible collaboration.

 
Remove these adsRemove these ads by Signing Up

Step 1: Create a Repository on the GitHub site

Picture of Create a Repository on the GitHub site
1_2.jpg

First, you'll want to register for a GitHub account. You can create as many repositories you want, as long as they are public. Anyone can download your public link and use your code and contribute to the archive. I usually don't upload a repository (a.k.a. a "repo") unless I'm at a good point with the code and ready to make it public.

The sample code I'm using here is called lenenbot, which is a Twitterbot that mixes John Lennon with Vladimir Lenin quotes. It takes the first half of one and mixes it with the second half of another.

Specific Steps on the GitHub site
Log in
Go to the Repositories tab
Click on the green New button, which will bring up this dialog
Enter a name for your source code repository
Select the Public radio button
Enter a 1-sentence description
Check the Initialize the repository with a ReadMe file
Choose the green Create Repository button

Now, you have an new repository. A default README.md file will be displayed in GitHub

DCengineer4 months ago

Well done basic tutorial... However, it is worth noting to viewers that Git does not require GitHub or even a server, and can be used locally. It would be a good idea to eventually explain some of the more powerful capabilities of Git such as interactive staging, branches, tags, .gitignore, merging, rebasing, resetting, and stashing.

There is a good book that I read that can be found on git-scm.com called Pro Git. I wanted to set up a server, so I read the whole thing (around 300 pages), but the first 3 chapters will give a you a basic understanding.

Also, in terms of a GUI tool, I have found that 2 in particular seem to work well.

Mac and Linux - Git Cola

Windows - Git Extensions

Note that Git Extensions will give you the option to install Git and a tool called KDiff3. I cannot say anything about the included Git installation due to the fact that I just installed it using the default installer from the git-scm website. I would not suggest installing KDiff3. Although it is very powerful, I have had issues with it - it seems that it doesn't like to apply the last change.

However, I have recently discovered a tool called Meld available for Mac, Windows, and Linux that provides a much nicer (if less powerful) interface. I would suggest using that for merging.

Summary:

Good Instructable.

Go to git-scm.com, find the Git Pro book, read it.

If you are on Linux or Mac install Git-Cola and Meld.

If you are on Windows install Git Extensions and Meld.

Hopefully you find these tools and resources as useful as I do.

scottkildall (author)  DCengineer4 months ago

Thanks for taking us to the next stage.

Indeed! There's a lot more out there. And most importantly, as you point out, Git runs separately from GitHub.

I'll look into these features you've suggested — a lot are beyond my current skills.

DCengineer4 months ago

One more consideration: look into Mercurial (also referred to as hg). It is far simpler than Git but less powerful. Just note that it is less common than Git, so sometimes you may run into compatibility problems. However, tools exist (specifically git-hg and hg-git) that allow you to work with other repos through your SCM tool of choice.

For those who don't know:

SCM = Source Code Management

CVS = Central Versioning System

SVN = Subversion (a common CVS tool)

DVCS = Distributed Version Control System (Git and Hg are examples of this, and have many benefits over CVS-based systems)

Git does not stand for anything. Its name is a self-insulting remark by Linus Torvalds (the creator of Git and Linux).