How to get started with Git and GitHub

As you probably already know, Git is a distributed source control system created by Linus Torvalds. Yes, the same guy who gave us Linux operating system. There are lots of resources that explain very well what Git is and how to get started on it. So I will writing about that, but will provide you with a list resources that I have found so far, at the end of this post.

GitHub is a web-based hosting service for software development projects that use the Git revision control system. GitHub offers both paid plans for private repositories, and free accounts for open source projects. As of May 2011, GitHub was the most popular open source code repository site ….. Wikipedia

GitHub itself has good documentation on how to go about setting it up and how to use it. So I will not be writing about that as well. Instead this post is about the how I started with Git and GitHub.

Being new to Git and GitHub, here are the steps that I took to get started on GitHub and how I installed Git locally and then used GitHub for Mac to connect to my GitHub account:

Sign-up for GitHub Account:

1. First signup at GitHub here : github.com
2. GitHub offers unlimited number of repositories, as long as they are made publicly available. I signed up for the free plan using my email id.
3. Remember your email-id and password  (pretty obvious ) which we will use when we setup Git locally and then to connect that to GitHub
4. You can login into your GitHub account, either using your email id or your username.

Install Git Locally:

1. Download the latest version of Git, for your particular OS, from here : Git Download
2. Then install the downloaded Git locally. It is a very straight forward install. I selected all the defaults and it worked just fine.
3. Test the git installation : Open Terminal / CMD and type the following:

$ git
usage: git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [-c name=value] [--help]
           <command> [<args>]

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find by binary search the change that introduced a bug
......

4. You should see the git usage help
5. To know where the git was installed type:

$ which git
$ /usr/local/git/bin/git

6. That tells you the path from where the git command was run. On my local machine git was install in the /usr/local/git directory.
7. Time for some git configurations. Setup the user-name and the email id for git, which are used for all the commits that you will do into Git
8. First setup you user-name:

# Sets the default name for git to use when you commit
$ git config --global user.name "Your Name Here"

9. Then set up your email id. Here use the same email that you used to register at GitHub in the previous section:

# Sets the default email for git to use when you commit
$ git config --global user.email "[email protected]"

10. You can also set up git to cache the GitHub password using the OSX Key Chain. Here is a very good link on how to set this up : Password Caching

Set up GitHub for Mac

1. Download GitHub for Mac from here : GitHub For Mac
2. GitHub for Mac is a Git Client, that runs on you local machine and makes it absolutely painless to connect to your GitHub account.
3. If you are working on a different OS, then download an appropriate client for your OS from the above link.
4. If you are using Git but not using GitHub, then there are lots of Git clients available. Here are a few listed at here : Git Clients
5. Install the downloaded GitHub for Mac. Installing is just copying the GitHub.app into the Applications folder.
6. Run GitHub app, either from the spotlight or from the Applications folder.
7. GitHub app will ask you for you GitHub account credentials i.e email id and password that was setup on GitHub account.
8. If you have setup the Password Caching as per the previous section, then this password will be saved into the OSX Key chain and GitHub app will not ask you to enter your password every time it interacts with the GitHub account.
9. Test the GitHub credentials and if the login works, then you are all set.
10. You can now create Git repositories locally and then sync them to the GitHub account, all from the easy to use UI provided by GitHub App.

Do let me know if the above steps worked for you while getting started with Git and GitHub.

Resources:

Here are a few resources to learn about Git and GitHub:
1. Articles and Videos on Git site itself : Git Documentation
2. Listen to tech talk by Linus Torvalds on Git at YouTube : Linus Torvalds on Git
3. Links curated by Git folks : Git – External Links
4. GitHub Help : Help Section

Leave a Reply

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

*

code