$ 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
问题>在当前文件夹中添加新文件abc.cpp
之后,为什么我仍然会在git中看到消息' working directory clean`?
谢谢
- 更新一个 -
$ 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)
答案 0 :(得分:1)
命令git status
不需要参数。您提供的参数branchABC
由git-status
解释为路径。因此git会检查名为branchABC
的文件或目录的状态。解决方案:只需使用以下命令之一:
git status
git status -b
在git-status
手册页中:git status [<options>...] [--] [<pathspec>...]
,因为branchABC
不是有效选项;它被解释为pathspec
。我同意git可能会发出一条警告:没有任何东西与路径branchABC
...
我在本地进行了测试。
$ 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
答案 1 :(得分:-2)
实际上abc.cpp
是一个新文件。因为它没有被提交到git。您所做的任何更改仅作为新文件进行跟踪。
添加文件并提交后,git将跟踪更改。
所以使用
添加文件git add abc.cpp
or
git add .
这样git就会跟踪文件abc.cpp
的变化。
您可以在这里尝试所有基本命令的在线练习