Home > front end >  Practical Git example (git status does not show untracked/changed file)
Practical Git example (git status does not show untracked/changed file)

Time:12-23

I'm currently reviewing Practical Git by Johan Abildskov in preparation for an upcoming job. The first example I came across seems to be impossible.

Here's how it starts:

$ ls
A B C D
$ git status
On branch master
nothing to commit, working tree clean
$ echo testing > A
$ git status
On branch master
nothing to commit, working tree clean

How did he get to this situation? If A is untracked, wouldn't git alert him about the untracked file? If A IS tracked, wouldn't git alert him that the file had changed?

I've been wracking my brain, but I can't figure out how your repository would get to this state.

CodePudding user response:

I can think of a few ways this can happen.

First, you could have the configuration option status.showUntrackedFiles set to no (either locally for this repo, or globally).

Second, you could have a .gitignore entry configured to ignore A.

Third, as Timothy Truckle mentioned in the comments, echo testing > A overwrites the contents of A with the string testing. If that was its content before the echo command, from git's perspective there'd be no change (i.e., nothing to report about in git status), since the content of the file is unchanged.

CodePudding user response:

Maybe, your A file is in the .gitignore file.

  • Related