Git for Beginners: Basics and Essential Commands

Version control is a must have skill today for every developer as it helps to collaborate and track the changes.

What is git?
Git helps to :

  • track the changes
  • who did the changes
  • revert the changes if needed
  • keeps the history of changes

Basic terminology git:

  • Repository:
    It is a folder which contains your project files and .git hidden folder to track the changes
  • Commit:
    It is a snapshot of particular project at particular time
    Each commit has a hash code and a message
  • Branch:
    A parallel line of development allow main.So the code in main branch is not affected and once the feature is developed you merge that in main branch
  • HEAD:
    It is a pointer that tells your current commit you are working on
  • Working Area:
    The place where you edit the files
  • Staging Area:
    Where you prepare your changes to be added

Git Basic commands:

  • git init : Initalizes git and creates .git hidden folder
  • git status : shows current status of file, if files needs to be added or committed.
  • git logs : Show commit history
  • git add : add the file to staging area
  • git add . : add the files to staging area
  • git commit : Save the staged changes as commit
DevegygiebyOL
DevegygiebyOL
Articles: 1190