Git Cheatsheat

Getting Started With Git

Git Cheatsheat

What is Git ?

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency

Git is available for all the platforms out there

Where to download Git ?

git-scm.com/downloads

  • Geting Started With Git

    • To check git installation__

      git --version
      
  • Setting up git for first time

    • Username

      git config --global user.name "<username>"
      
    • Email

      git config --global user.email "<email>"
      

      If in future you want to link git to github your email should be same as on github

  • Initializing Git

    You should be in directory where you want to store files or track files

    In git Repository simply means Folder

    • Local Repository

      git init
      
    • Online Repository

      git clone <url of repository>
      
  • Staging and Commiting Changes

    • Staging

      • Status of files
        git status
        
      • Adding files to Staging area
        git add .
        

        It will add all files from current directory to staging area

        For adding specific file to staging area use below command

        git add <filename1, filename2, ...>
        
      • Removing files from Staging area
        git reset "<filename>"
        

        If you want git to ignore some files from trackin you have to create a .gitignore file in root of directory with specifing files you don't want to track

    • Commiting Changes

      git commit -m "<your message>"
      

      Here -m used for message

      Your messege should be informational about changes you made for someone else to understand

    • Pushing Local to Github

      • Adding Remote Repository
        git remote add origin <url of remote repo>
        
      • After adding remote Repository
        git push origin master
        

Now you have learned about staging and commiting changes on git locally and remotely on github

Happy Learning