Introduction to Git

Basic Git Commands

gitcoverimage.png

  • What is Git?

  • Features of Git

  • Git workflow

  • Git Commands

What is Git?

Git is a free and open source distributed version control system used to handle very small to large projects efficiently. It is developed to co-ordinate the work among the developers. The version control allows us to track and work together with our team members at the same workspace.

Features of Git

  • Branching and Merging
  • Small and Fast
  • Distributed
  • Staging Area
  • Free and Open Source

Git Workflow

image.png

Git Commands

  • It is a good idea to introduce yourself to Git with your name and public email address before doing any operation. To configure username and email for git:
         $ git config --global user.name "Your Name Comes Here"
         $ git config --global user.email you@yourdomain.example.com
    
  • To initialize the working directory:

        $ git init
    
  • To add changed file of a working directory to the staging area:

        $ git add filename
    
  • To add all the changed files of a working directory to the staging area:

        $ git add .
    
  • To know the status of the changed files in the current working directory:

        $ git status
    
  • To commit the files from staging area to git repository:

         $ git commit -m "message for the commit"
    
  • To view the history of your changes:

        $ git log
    
  • To clone the copy of an existing repository into a new directory:

       $ git clone repo-url
    
  • A single Git repository can maintain multiple branches of development. To create a new branch named "development", use
      $ git branch development
    
  • To list the branches of a working directory:

     $ git branch
    
  • To push all local branch commits to the corresponding remote branch:

     $ git push
    

Did you find this article valuable?

Support Cloud Computing & Devops Tools by becoming a sponsor. Any amount is appreciated!