Things We discussed

What is Git

Git is a distributed source version control tool. Okay so what does it mean ? let's start with source version control it means that it allows us to track versions of source code as we develop any software. distributed here indicates that its not centralized server based but the history is stored in every user's own copy of the repository aka git clone

Why was it created and who was it created by

It was created by linux software foundation to help them better colloborate on linux kernel, as tools existing back then weren't good enough for their needs.

What's the difference between git and github/gitlab/bitbucket

Git is the tool used to create and manage source code versioning and management, github and its competition are like dropbox/google drive which host these repositories and allow administrative functionality on top of these repositories using the git.

what's an ssh key

SSH key is a 2 part key generate by running ssh-keygen command on your machine, running this command will create 2 key files in ~/.ssh folder. although the name can be changed the default name is id_rsa and id_rsa.pub the .pub file is the sharable public key that you can show as your id card, the id_rsa file is the secret key that'll prove that you are who you say you are in the publickey.

Setting up ssh key on github

  1. Generate ssh key
$ ssh-keygen

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/uday/.ssh/id_rsa):
Created directory '/c/Users/uday/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/uday/.ssh/id_rsa
Your public key has been saved in /c/Users/uday/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:dwhVWqrTGbaIoHhqhq6xC//rgvqxeph78stH+HhjhTM uday@567aef87-74bb-4b24-bf63-0419604cc2e4
The key's randomart image is:
+---[RSA 3072]----+
|          ..o    |
|         . +     |
|    .   . =      |
| . . . . * =     |
|. o. .. S * .    |
|.o. E .  o .     |
|=*.+ +           |
|X==o*            |
|X@BO+o           |
+----[SHA256]-----+
  1. Copy the contents of the file id_rsa.pub
  2. Go to settings on your github page by clicking on your profile picture and selecting settings in the options menu that opens
  3. Go to ssh keys section (sometimes also called ssh and gpg keys)
  4. Click new SSH key
    1. Add a title that helps you where you generated the key i.e machine name and stuff
    2. Paste the content copied in step 2 in the key section
    3. The type of the key is going to be authentication key incase that's asked
  5. click on Add key

Cloning the repository

Cloning a repository is akin to downloading a folder from google drive/ dropbox but with a super-power. Which is ... version tracking. The clone command will copy all the files along with history and setup necessary structures to operate the git command in that directory.

Go to the repository and click on clone repository which is usually the right most button on top of directory structure of a code repository. You'll have 2 ways to clone the repository one using https in which case you'd have to enter your password and username each time you clone the repository. other using ssh key which will serve as your id card when you go and fetch data from github or similar server.

Git terminology breakdown

  1. Clone -- Download repo on to local machine
  2. Branch -- A version of the code that can be independently tracked and worked on.
  3. Checkout -- aka checkout to a branch, opening a branch to work on
  4. Commit -- Saving changes to the git repository. Commit is both a verb and a noun, the noun part means the changes made when saving
  5. Push -- Upload to github or similar services
  6. Remote -- URL of the repository on github ssh or https. This allows the local git client to know where to upload. Remote has 2 components to it
    1. name -- The default name is called origin
    2. url
  7. Pull Request/Merge Request -- It simply means that we want to combine 2 branches and have created a request for that to happen, this will be shown on github with a neat comparision UI that shows the difference between the 2 branches

Things i got wrong / Mis understood

Sorry ! I Don't remember, please raise it if you do

Things We missed

Typical git workflow

# Clone the repository one time thing
$ git clone git@github.com:udaykrishna/javaprep.git # downloads the repository and places it in the folder ./javaprep

$ git checkout -b new-branch # creates a new branch to work on my changes

$ git add file1 file2 # add in files i changed to staging area (aka select files to commit, 
# equivalent to checkmarking multiple files on windows when moving)

$ git commit -m "added file1 and file2" # save my changes to git. its safe now <3

$ git push origin new-branch # telling git to push(upload) last saved state to `new-branch` branch of origin. 
# Origin is default remote url which automatically gets added when cloning repository

After all this we open github and create a merge request