As an IT pro, you may have heard of Git and GitHub but may have little to no experience with them. In this article, I'd like to change that.

A growing trend that has polarized a lot of IT professionals is code. More than ever before it seems like industry giants and are pushing for everyone to learn to code. Software is everywhere and is, according to Marc Andreessen, eating the world. To build software or scripts, it's critical to capture code somewhere and save a history. Source control is where to do this.

One of the most popular source control systems is Git. Git is a system that allows developers to check in code, revert to old versions of code, create branches of code, and a whole lot more. GitHub is the popular service that extends the Git version control software. GitHub makes not only committing code to a repository possible but also makes collaboration with others on a project much easier.

One of the first gotchas I see from newcomers to source control in general is not understanding the difference between Git and GitHub. It's important to know that Git is not GitHub. Git has been around since 2005. Git is a source control repository that allows multiple people to manage their code. GitHub on the other hand is a distributed system that manages multiple copies of Git repositories and can merge them into various branches. You can loosely think of Github as a front end to Git with a lot of social features added on top.

When using GitHub for the first time, you'll need to setup a repository. A repository or repo is a collection of code, project artifacts like binary files, documentation, and so on. This represents everything it takes to make your software or script project run. A repository can be a single script, or it can be a huge, multi-thousand file project that thousands of people maintain. Creating a repository is the first step in getting involved with GitHub.

Once you have set up the repository, I then recommend editing the readme file. Every GitHub repository has a readme file displayed on the repository's front page. The readme file is written in Markdown and usually has the name of the project, its purpose, requirements, goals, and so on. The readme file is basically a high-level summary of the project and what a newcomer might expect when using it.

After setting up your repository, I recommend downloading the GitHub desktop client. The desktop client is an easy way to link your local computer to your GitHub account so that you can sync any local changes in your Git repository up to GitHub. Once you've downloaded the desktop client, you'll then need to set up a repository locally. If you've already created a repository on GitHub.com, you'll need to clone that repository to your local computer as shown below.

Cloning a GitHub repository

Cloning a GitHub repository

After you've cloned the repository, you'll have all the files of that repository on your local computer. You can now add files, change files around, and remove stuff at will. Once you are comfortable with the changes you've made and you'd like to contribute those changes to the GitHub project, you'll then sync those changes to the repository if you have full access. In our case, since you've created a personal repository, you are the sole owner and are allowed to sync changes just to the master branch. The master is the root of the project with branches coming from the root. For more information about branching, check out the Branches in a Nutshell article.

However, if you've cloned a repository you don't own from another project and have changes you'd like to merge to the project, you'll have to issue a pull request. A pull request is a GitHub way of telling the project owner you have some changes you'd like to merge into the project. You're asking them to pull your code into theirs. After the creation of a pull request, the project owner will receive a notification, review your proposed changes, and as they see fit, will either merge your changes into the existing codebase or deny it. The pull request is the approval gate between you and a project.

Subscribe to 4sysops newsletter!

We've just scratched the surface with Git and GitHub. For a complete breakdown of most of the common concepts, it'd be useful to check out Git and Github: A Beginner's Guide for Complete Newbies.

+3
avataravatar
2 Comments
  1. Fox 4 years ago

    It might clarify more the difference between GitHub and git, if you'd mention some alternatives to GitHub, like GitLab.

    0

  2. I'm using Git for Windows and have GitHub account. On my mind it's more convenient to use Git commands to pull or push changes instead of GitHub desktop client.

    +1

Leave a reply

Please enclose code in pre tags

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2021

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account