How Git works? Working directory, Staging area and Commit, a Git Workflow

This article teach How Git internally work with respect to working directory, staging area and commit, a Git workflow.

As shown figure, Git has 3 component in its workflow.

  1. Git working directory: Where you intialize git repo. All your working on content is done here. You modify content, copy content and add content here. Once you sure your conent is final then you add it to git repo. Working directory is like your rough work in you paper with pencil and as many time you rough pencil letters and again write.
  2. Git Index/Staging area: Once you sure you want to add some content from your working directory to final repo, then you add content with “git add” command and that content are push to Staging/Index area. You can move forward and backword from staging area to non staging or commit like pull, reset, clone, etc. Its intermediate place where you gather content for future commit. Staging area is use like you write in paper with pen where no rough work needed
  3. Git Local History: When your data/content is ready to commit in repository that time you can put your content in repo via commit. Commit will add data point like your backup restore point. You can reset your commit whenever you want like restoring backup. Commit is mark of you data point so you can use it also at merge or go back or forth. Local History is like your final note which is complete and you can refer it whenver you need with specific commit point