Yet Another Git & Github Introduction

Imagine, you are in a team and the whole team is responsible to develop a single page. So, each member is assigned to implement a particular section of the webpage. One way would be developing a section individually and then sending the whole package to another person through email so that s/he can implement his section. In the meantime, if you want to change a little segment as little as a single line, you have to wait until another person is finished. Then, s/he will send the package again and you can work on it.

Super Inefficient

That’s where Git & Github comes in. They are different. Git is basically used for version control. You can work simultaneously, merge segments, use branching techniques in Git. Github is basically used to hold online repositories. Github can be used through the website or it can be used along with Git.

Initial Steps:

  • Install homebrew (https://brew.sh) for mac. Then, using homebrew Git can be installed

brew install git

  • Set global variables such as my name, email inside git config
  • Set preferred editor for git
  • Set “end of line” so that code written with windows/mac doesn’t have carriage return added while pushing on Github

For mac:

git config –global core.autocrlf input 

For Windows:

git config –global core.autocrlf true

  • Go to the project folder using cd
  • Initiate git with 

git init

  • Create files in the project directory. Add those files to the staging area after making changes.

git add file.extension 

OR

git add .

  • Change files as much as needed and add to the staging area using the same command.
  • Commit changes to local repository

git commit -m “change message”

The next step would be to set SSH encryption key to Github after generating locally through ssh-keygen command. The following Github Gist code segment contains full basic Git command list and the proper way to setup Git & Github to push the codes to online Github repository.