top of page

Git Tutorial

Git Staging Environment

What Is Staging Environment/Area In Git ?

Staging and commit are the core concepts of git. Any kind of modification you want to do on your files whether it is adding, editing or removing of files, first you must add the files to a staging environment.
All the updates/changes are tracked here.
Staged files are ready to be committed to the repository you are working on.
In staging, there are following aspects :
  • Untracked changes/files - Changes/Files that are not pushed to staging environment but are in git repository are untracked.

  • Tracked changes/files - Changes/Files that are present in staging environment are tracked.


Staging area covers three kinds of commands :
  1. Git status command

  2. Git add command

  3. Git remove command

Let's consider a git repository named 'GitSample', contains three .txt files as:

(i) user_id

(ii) user_name

(iii) user_data

(iv) user_history






Git Status Command
To check status of the staging of a git repository, browse to the directory of git repository and enter the command ' git status ' on git cmd. It will show you all the unstaged, staged and untracked files of present git repository.




Git Add Command/How Files can be Staged ?
We use ' git add ' command to add a file to staging area.
It adds the changes in the working directory to the staging area and tells the git that there are few updates in the project, which user wants to commit next.
Now, browse to the directory of git repository i.e. ' cd automationhub/gitsample '.

  • To add single file to staging, use the command ' git add filenamewithextension ' and check the status.





  • To add more than one file, ' git add filenamewithextension filenamewithextension.... ' and check the status.




  • To add all the files to staging at once, ' git add * ' and check the status.









Git Remove Command/How Files can be Unstaged ?
Git 'rm' command removes tracked changes from the staging area. This command tells the git that the updates which were pushed to staging earlier with git add command, are not ready to commit and unstaged them but the changes still exist in Local Repository.
To practice the command, let's try on the same files which have been added earlier :

Again, browse to the directory of git repository i.e. 'cd automationhub/gitsample'.
  • To remove single file from staging, use the command ' git rm --cached filenamewithextension ' and check the status.




  • To remove more than one file, ' git rm --cached filenamewithextension filenamewithextension.... ' and check the status.



  • To remove all the files from staging at once, ' git rm --cached * ' and check the status.





Refer next page Git Commit
bottom of page