There are several stages for a file.
- untracked files
- tracked files with non-staged changes
- tracked files with staged changes
- committed changes
You can see the stages of the changes when you
git status your project folder.
Your branch is up-to-date with ‘origin/master’.
Changes not staged for commit: (use “git add <file>…” to update what will be committed) (use “git checkout — <file>…” to discard changes in working directory)
modified: app/controllers/folders_controller.rb modified: app/views/folders/show.html.erb modified: config/routes.rb
Untracked files: (use “git add <file>…” to include in what will be committed)
no changes added to commit (use “git add” and/or “git commit -a”)
The file is usually new and haven’t been tracked yet.
NOTE: If you don’t want a specific file to be tracked. You should add it to
.gitignore file. Don’t just leave that file there showing up every time when you view the
git status. It’s because we want to make sure we can reach the state of clean working directory.
Here is how a clean git status looks like:
On branch master
nothing to commit, working directory clean
Changed but un-staged:
The file is under tracked and there are changes since last commit.
The changes is marked and will be added to repository in next commit.
The changes are stored in the git repository. You can’t see it in
git status. But you can view them by using
When we learn how to undo changes by using
git reset, we will need the concept of these stages.