如何指示git停止跟踪外部目录?

时间:2014-06-13 19:44:01

标签: git github

出于某种原因,$ git status向我显示了对其他目录的更改:

如何指示git停止跟踪外部目录?

2 个答案:

答案 0 :(得分:2)

文件不在您的存储库之外;您位于存储库的子目录中。

$ find
.
./subdir
./subdir/bar.txt
./foo.txt

$ git init .
Initialized empty Git repository in /tmp/ikegami/.git/

$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       foo.txt
#       subdir/
nothing added to commit but untracked files present (use "git add" to track)

$ cd subdir

$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       ../foo.txt
#       ./
nothing added to commit but untracked files present (use "git add" to track)

如果您当前的目录被认为是您的存储库,那么您使用的是git init而不是git init subdir,或者您使用的是git clone url .而不是git clone url subdir

答案 1 :(得分:1)

也许问题不清楚,你真正想要的是:

git status .