3
$ git --version
git version 2.5.3

$ git branch
* feature/branchABC

$ git status -b branchABC
On branch feature/branchABC
Your branch is up-to-date with 'origin/feature/branchABC'.
nothing to commit, working directory clean

$ echo "abc" > abc.cpp

$ git status -b branchABC
On branch feature/branchABC
Your branch is up-to-date with 'origin/feature/branchABC'.
nothing to commit, working directory clean

Question> After I add a new file abc.cpp in the current folder, why I still see the message 'working directory clean` in git?

Thank you

--Update One--

$ git status
On branch feature/branchABC
Your branch is up-to-date with 'origin/feature/branchABC'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        abc.cpp

nothing added to commit but untracked files present (use "git add" to track)
Chris Maes
  • 26,426
  • 4
  • 84
  • 113
q0987
  • 31,246
  • 61
  • 222
  • 356

2 Answers2

1

the command git status doesn't require an argument. The argument branchABC that you provided is interpreted by git-status as a path. So git checks the status of a file or directory named branchABC. Solution: just use one of the following commands:

git status
git status -b

in the git-status man page: git status [<options>...] [--] [<pathspec>...], and since branchABC is not a valid option; it is interpreted as pathspec. I agree that maybe git could have put a warning that there is nothing matching the path branchABC...

I tested this locally.

$ git status
# On branch test
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       spec/a
#       src/a

$ git status src
# On branch test
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       src/a

$ git status non-existing-path
# On branch test
nothing to commit, working directory clean
Chris Maes
  • 26,426
  • 4
  • 84
  • 113
-2

Actually abc.cpp is a new file. Since it is not commited in to git. Any change you made is tracked only as a new file.

Once you add the file and commit, git will keep track the changes.

So add the file using

git add abc.cpp

or

git add .

So that git will keep track the changes of the file abc.cpp. You can try an online excercise for all basic commands here

https://try.github.io

Viswanath Lekshmanan
  • 9,155
  • 1
  • 37
  • 60
  • That does not answer his question: normally an untracked file should show up (if it is not in gitignore), and it doesn't... proof is his edited question: using only git status; the file shows up... – Chris Maes Jan 08 '16 at 16:04
  • @ChrisMaes It shows the file as `untracked` as you can see his updated answer. Hope you can see as the file as untracked – Viswanath Lekshmanan Jan 10 '16 at 15:02
  • in the update of his question it shows up as untracked, allright. But his question is not "why does this file show up untracked", but `why I still see the message 'working directory clean' in git?` – Chris Maes Jan 10 '16 at 15:48
  • your information is not wrong, but it just isn't the answer to this question. – Chris Maes Jan 10 '16 at 15:49
  • @ChrisMaes why I still see the message 'working directory clean' in git?` This what i have answered. Git is not tracking the newly created file since is not added. You can check it here . you just answered in a complex instead of simple words http://programmers.stackexchange.com/questions/69178/what-is-the-benefit-of-gits-two-stage-commit-process-staging – Viswanath Lekshmanan Jan 10 '16 at 16:07
  • You say you still see the message "working directory clean'; which command are you using? If you just use `git status`, as explained in my answer above, then you should see the untracked file (if you have one, that is). – Chris Maes Jan 10 '16 at 16:12