Git uses three sections on individual machines. They are
- Working directory
- Staging Area
- Local Repository
Initially, the developer will create files in the working directory. All the files which are present over here are treated by Git as untracked files.
From the working directory we send the files into staging are, this is a intermediate buffer zone. And it can be called as git cache area.
From Staging area we commit the files into the Local Repository.
Check the status of working directory.
Add Files to Staging Area
After your work done, it’s time to add the files to the staging area. To add a certain file, we can run git add file_name command. If we want to add multiple files at a time, just run git add . (dot after add command). See the below examples.
Here, we have four untracked files. Add file1 to the staging area and check the status.
File file1 added to staging area and remaining files are in untracked state and try to add multiple files with names.
Remove Files from Staging Area.
The files added into staging area can be removed and brought back. To bring the file from stating area, use below command.
We can also use reset command for bringing the files from staging area into working directory.
To add all files to staging area, see the below command.
To remove bring all files from staging area, see the below command.
Go to next chapter to learn how to commit the files to Local Repository from staging area.