Introduction to Git

How to keep track of changes to work using Git & GitHub

Introduction to Git

What is Git?

What is a version control system?


Why do we need a version control system?

To avoid sistualtions like this.

Image Credits: notFinal.doc by Jorge Cham,
https://www.phdcomics.com

Git vs. Github

Git is a version control system created by Linus Torvalds.

Github is a commercial service that offers git hosting in the cloud. It is very popular among the developers and it is almost the defacto standard for hosting code.

It is possible to use Git without using Github. However, for this course, we’ll use both Git and Github.

Setting up Git

Setup git by configuring your name and email address in git.

$ git config --global user.name "Anand Chitipothu"
$ git config --global user.email "anand@example.com"

Please use your name and email address in the example above. Also, make sure the email address is same as what you have used when creating an account on github.

Setup ssh-keys

$ ssh-keygen -t ed25519 -C anand@my-laptop-name

That will output the following:

Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/anand/.ssh/id_ed25519):

Just press Enter.

Enter passphrase (empty for no passphrase):

If you are using your own laptop, leave this empty. If you using the lab computer, pick a strong passphrase as that allows pusing any changes to your repositories on github.

Create a Repository on Github

  • Login to github
  • Create a new repository with name git-practice.
  • Add Repository name and Description
  • And select Add a README file.

Clone the repo

Clone the repo to your local computer.

git clone git@github.com:anandology/git-practice.git

Add a new file to the repo

$ touch planets.md

$ git status