Changes to be committed:
Changes not staged for commit:
Untracked files:
What do these categories mean? |
first you need to understand that git repository consists of (in this order):
1. Working tree
2. index
3. Local repository
4. remote repository
Working tree is where your working tree is, that is your code and project files on your local computer.
index is where you add or "stage" your changes from working tree to index, index resides also on your local computer
Local repository is also on your local computer and it's a place where you commit staged files, from index, that is you commit them to local repository.
finally remote repository is as the name implies remote git repo such as Github.
OK, now to the answer:
when you do
git add you move your changes from working tree to index.
when you do
git commit you mark your index as ready for push, that is you "move" it to local repository.
Finally when you do
git push you copy commits (commited code from index to local repository) from local repository to remove repository.
note: that index does not contain any files (unlike, working tree, local repo and remote repo), I use "move" word here to simplify explanation
then if you continue to do some work in your code(working tree) these new changes are not staged or comitted yet, so when you do
git status you see them as
Changes not staged for commit.
note that staging means adding files to index, and commiting means adding files from index to local repo, and push means copy from local repo to remote repo.
now if you do
git add . and then continue to work on code and do
git status you'll see new changes as
Changes not staged for commit and
Changes to be committed (which are changes which you
git add previously, prior to making new further changes)
working tree clean means you commited all your local changes to local repository (or remote repo is there are not commits to be pushed)
Untracked files
untracked files are files or code in your working tree which you did not
git add *initially* to track them (that is to be able to add them to index in the future, and then commit and push) you use
git add. to track files which means that git tracks changes on them, you only
git add them once, subsequent
git add means adding them to index (not start tracking them)!
Hopefully this gets you a better picture of how git works, if you have more questions feeel free to ask.