Learn Github and Git to Efficiently manage your project

Abhishek Mani
4 min readOct 18, 2020

In this article we will find out the simplest way for managing different versions of project , keeping track of code , how branching works etc.,

Why Version Control System :

You can keep track of all the version of your project as a snapshot and also well documented

versions can be named properly and in any case if central server crashes , a backup is always available in your local servers

What happens when version changes :

Version control system (Github) provides you the complete description of your project history for example what exactly was changed in any particular version , when did the change took place hence you can analyze how your project evolved version by version

Version control tools:

Git , Subversion , Mercurial are some of the famous version control tools , in which git is most widely used version control tool among all

What is Repository:

Repository can be understood just as a space for your files , where you can keep your code files

Git and Github:

Git is basically a version control tool , that will allow to push the data to the central server i.e., Github

Github is nothing but that allows you ton store your project files , just like social sites

Feature of Git and Github:

Distributed : Allows distributed development of code , every developer has a local copy of entire development history and changes are copied from one repository to another

compatible : Compatible with existing system and protocols

Non Linear : Supports non-linear development of software, it basically records the current state , Git facilitates non-linear with branching .
It takes only few seconds to create and merge branches
Master branch always contains the production quality code

Lightweight : It compresses the entire file when we store it in local repository

Speed : Fetching data form the local repository is 100 times faster than remote repository
Git is one order of magnitude faster than other version control tools
This is written in C , which is not like high level language but machine level language which reduces the runtime overhead

Open Source :You can modify its source code according to your needs

Reliable : In case system crash , the lost data can be recovered from the local repository of collaborators

Secure : Uses SHA1 to name and identify objects
Every file and commit is checksummed and is retrieved by its checksum at time of checkout

Types of Repository:

Two types of repository :

  1. central Repository
  2. Remote Repository

Lets finally learn the Git command and operation for managing the project

  1. Download git bash from here : https://git-scm.com/downloads
  2. Create a folder name XYZ(anything you like)
  3. move inside the folder
  4. open git bash here (where you want to create the project)
  5. First Create Github repository on https://github.com/new you can make it public and then initialize it with readme file (this will give you the initial description or data about your file )

6. Lets start by creating a local repository

command 1: git init

7. Copy link of the repository as shown below

8. Syncing or linking to the remote server using below command :

git remote add origin “copied link here”

9. Now we are connected to the remote server then we can make pull from the remote repository using below command

git pull origin master

10. Lets create a example file in the current folder , file1.txt and then write anything in this file

11. Lets commit this update using the following command

git status this command lets you know about the current repository if any file is there to for commit

git add or git add -A (in case of multiple files )

git commit -m “type some message”

1st time commiting may fall in to error use below command to get rid of that error

git config — global user.email “ usermail@xyz.com”

git config — global user.name “myname”

12. Branching

git branch branchname

to change to this branch use the below command:

git checkout branchname

make some changes to the file , whatever the changes happen after commit that will take place in the branch and not in master branch until merge

use again same command as in point 11 above

12. Merging Branch checkout to master and you wont see the update there . Now in order to update your master branch use the below command

git checkout master

git merger firstbranch

13. Renaming branch name

git branch -m <older name> <new branch name>

14. Now lets finally move all the files to central repository

generate SSH key on git bash using the below code :

ssh-keygen (copy this ssh key generated in gitbash)

now go to github setting and then SSH and GPG keys paste the above copied ssh key there

use the below command

ssh -t git@github.com

15. Now we are read to push the files to central repository

git push origin master

Workflow

--

--

Abhishek Mani

I am software developer , experienced in python web app development , javascript , data science