Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does dirty/clean working directory mean?

Tags:

git

From Version Control with Git by Leoliger 2ed,

After you commit the addition of the new file into the repository, git status indicates that there are no outstanding, staged changes to be committed.

 $ git status
 # On branch master
 nothing to commit (working directory clean)

Git also takes the time to tell you that your working directory is clean, which means the working directory has no unknown or modified files that differ from what is in the repository.

Does "modified" files mean the same as tracked files that are modified but uncommitted? Does "tracked files" mean files that have been committed before?

What does "unknown" files mean?

Does ignored files not count?

Does untracked but not ignored files count as "unknown"?

Btw, in Pro Git by Chacon:

$ git status
On branch master
nothing to commit, working directory clean

This means you have a clean working directory – in other words, there are no tracked and modified files.

like image 433
Tim Avatar asked Jan 02 '16 22:01

Tim


3 Answers

Does "modified" files mean the same as tracked files that are modified but uncommitted?

Yes. When you make changes to a file that git is tracking, git sees that there is a difference between the current state of the file and the last committed state of that file. Until this file is committed, git status will show this file as modified and your working directory will be dirty.

Does "tracked files" mean files that have been committed before?

Yes. Tracked files are files that git knows about. That is, files that you have previously made a snapshot of by using git add <file_name> and git commit.

What does "unknown" files mean?

As far as I know, there is no concept of "unknown" files in git terminology. I'm assuming what the author meant by saying this is that there are no untracked files present in the directory. If there are untracked files, git will show something like this:

nothing added to commit but untracked files present (use "git add" to track)

after listing the files that are not being tracked by git.

Does ignored files not count?

Ignored files are files that you have explicitly told git that you do not want to track. So, if you have a file called .mysettings and you add .mysettings to your project's .gitignore file, git will never bother you by saying "Hey, your working directory isn't clean because you've got this untracked .mysettings file here." when you run the git status command.

So yes, your ignored files do count in a way. If they weren't ignored and just remained untracked, your project directory would never be considered "clean" by git.

Does untracked but not ignored files count as "unknown"?

I believe that is what the author was getting at by using the word "unknown", yes.

So a clean working directory is a working directory that has:

  1. No untracked files.
  2. No modified files that are currently part of git's index of tracked files.
like image 101
Zajn Avatar answered Oct 04 '22 19:10

Zajn


Does "modified" files mean the same as tracked files that are modified but uncommitted? Does "tracked files" mean files that have been committed before?

YES

Does ignored files not count?

YES git commands does not effect ignored files until you explicitly say so.

Does untracked but not ignored files count as "unknown"?

NO untracked but not ignored is just to simple keep the file in the repository so other collaborators/contributors can get those files and does not track the changes in those files.

(I am not sure what is unknown files in git)

like image 40
Skyyy Avatar answered Oct 04 '22 19:10

Skyyy


As you found out - basically it means that there are no untracked files or no files to commit.

All your files are ignored or committed


Does "modified" files mean the same as tracked files that are modified but uncommitted?

Yep, but you can use git add -p so your file can be both modified and staged at the same time.


Does "tracked files" mean files that have been committed before?

Exactly, tracked files are files which git has history about them (committed)


Does ignored files not count?

No, they are ignored...


What does "unknown" files mean?

There is no such a thing in git, you have untracked files which are files that git has no history about them so the are untracked, git has nothing to compare them to


Does untracked but not ignored files count as "unknown"?

Again read the previous paragraph


enter image description here

like image 39
CodeWizard Avatar answered Oct 04 '22 18:10

CodeWizard