Git and GitHub :The Basics

Git is a distributed version control system that works on providing solution to problems like sharing of code , versioning etc.

Maintaining the history of our project. Sharing code on GitHub and sharing our project around the world, Git helps us to know a what particular point of time and where the code changes are made.

GitHub: GitHub is an online platform that helps us to host our git repository. Repository: The folder is where all the changes are saved.

Centralized Version Control System and Distributed Version Control System

Some Centralized Version control system are SVS and CVN . Git is a Distributed Version Control System.

Centralized Version Control System: To share the code we had to put the code to a centralized place like SVN and from here developer used to pick up the code changes. But there are chances of this system going down and the entire work may hamper.

Distributed Version Control System: To share the code we had to put the code to a Distributed system where code changes can be picked or a copy of the distributed system and make code changes. The changes are done in the copy.

FORK: A fork creates a completely independent copy of the Git repository

Installing Git

  1. Visit Git Official Website: https://git-scm.com/downloads , and depending on your operating system download git.

  2. To check if git is installed just type command git --version on windows and git version on Linux

Commands Used in Git

  1. To initialize an empty git repository in our project folder.

     git init
    

    If we want to know if git repo. is initialized in our folder run the command ls-la to and if we get a (.git) file then we can confirm git repo is initialized.

  2. To know about the current repository status to know if any untracked files are present we use git status

     git status
    
  3. To tell the git to track the file in our folder.

     git add <File_name>
    
     //Or if you want to track all files we that file 
     git add
    
  4. If some one made 1 change to our file, to check the changes in that folder we use git diff command.

  5. To commit the changes to keep track of versioning.

     git commit -m"<Message we want to pass related to change>"
    
  6. To see all our commits.

     git log
    
  7. If we want to go to the previous commit/version. First we run git log command. Copy the commit id and run below command.

     git reset --hard <commit_id>
    

Creating a GitHub Repository

Head over to GitHub's official website. Register with your email ID. And create the repository. Refer this video resource by Abhishek Verramalla

https://www.youtube.com/watch?v=fIMySI_gZJU&list=PLdpzxOOAlwvIKMhk8WhzN1pYoJ1YU8Csa&index=12

My Github Profile: https://github.com/VijayVPatil