Git has three main states that files can reside in i.e.
- Committed
- Modified
- Staged
Committed means that the data is safely stored in your local database. Modified means that you have changed the file but have not committed it to your database yet. Staged means that you have marked a modified file in its current version to go into your next commit. The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit.
The basic Git workflow goes something like this:
- You modify files in your working directory.
Example :- Make changes in the file - You stage the files, adding snapshots of them to your staging area.
git add
prepare the content staged for the next commit.git add a.html git add b.html
- You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git local directory.
git commit -m "Changes for a and b"git add c.html git commit -m "Unrelated change to c"
A file goes through various life cycle. Each file in working directory can be in one of two states: tracked or untracked. Tracked files are files that were in the last snapshot; they can be unmodified, modified, or staged. Untracked files are everything else – any files in working directory that were not in last snapshot and are not in staging area. As a file is edited, Git sees them as modified, these files can be staged in staged area and then commited.
Reference