Git and Basic Commands

What is Git??

  • Git is a version control system for tracking changes in computer files.
  • It is developed in 2005 .
  • It is distributed version control system. There are other centralised version control systems like SVN.
  • It coordinates work between multiple developers.
  • We can identify who made what changes and when they are made.
  • We can alse revert back changes any time.
  • We will have local and remote repositories.
How it works??
  • Git will keep track of code history.
  • It takes snapshots of our files, snapshots are taken when we commit changes.
  • Before committing we need to stage the changes.
  • The process goes as follows.   
     Create a local repository. Initialize it as a git repository. Add files and make changes.Stage the files. Commit the changes. Push the changes.
Basic Commands
git init //Inialize local git repository
git add <file> //Add single file to index
git add -A      // Add all files to index
git commit -m “Your message” // commit the changes in index
git push    //push changes to remote repository
git pull  //pull latest from repository
git clone //clone repository into a new directory