0

ファイルのいくつかのエントリの作成に問題があり.gitignoreます。.次のように、名前にが含まれるディレクトリがあります。

Thing1.This/bin  
Thing1.That/bin 
Thing1.TheOther/bin  

bin ディレクトリを除外したい。これらのディレクトリは明示的に追加できますが、これを面倒にするものがたくさんあります。また、これらの両方の行を使用してみましたが、どちらも機能しませんでした:

*/bin
[Bb]in

これはどのように指定できますか?

私はWindows 7で作業しています。

4

2 に答える 2

2

サブディレクトリ内のディレクトリを gitignoreに追加する場合binは、次の構文を使用できます。

**/bin/

リポジトリ内のすべての bin フォルダーを無視します。ドキュメントから:

先頭の " **" とそれに続くスラッシュは、すべてのディレクトリで一致することを意味します。たとえば、" **/foo" は、パターン "foo" と同じように、任意の場所のファイルまたはディレクトリ "foo" に一致します。" **/foo/bar" は、ディレクトリ "foo" の直下にあるファイルまたはディレクトリ "bar" と一致します。

于 2013-11-07T18:10:20.823 に答える
1

私は走った:

$ for number in $(seq 1 9); do mkdir -p Thing$number.Thing/bin; done
$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   makefile
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   b+tree
#   b+tree.cpp
#   cswap.c
#   qs.c
#   qs2.c
#   qs3.c
#   select.c
#   shm
#   shm.c
#   sleepers-awake.c
no changes added to commit (use "git add" and/or "git commit -a")
$ 

ディレクトリにはコンテンツがなく、git追跡するものがないため、追跡する必要があるものとしてリストされていません。ディレクトリにファイルを追加しました:

$ for d in Thing?.Thing/bin; do cp qs.c $d; done
$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   makefile
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   Thing1.Thing/
#   Thing2.Thing/
#   Thing3.Thing/
#   Thing4.Thing/
#   Thing5.Thing/
#   Thing6.Thing/
#   Thing7.Thing/
#   Thing8.Thing/
#   Thing9.Thing/
#   b+tree
#   b+tree.cpp
#   cswap.c
#   qs.c
#   qs2.c
#   qs3.c
#   select.c
#   shm
#   shm.c
#   sleepers-awake.c
no changes added to commit (use "git add" and/or "git commit -a")
$

git追加が必要なディレクトリが表示されるようになりました。私は次のように編集.gitignoreして追加しましたThing*.Thing/bin

Thing*.Thing/bin
*.a
*.dSYM
*.o
*.so
*~
a.out
core
posixver.h
timer.h

私は再実行しましたgit status

$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   .gitignore
#   modified:   makefile
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   b+tree
#   b+tree.cpp
#   cswap.c
#   qs.c
#   qs2.c
#   qs3.c
#   select.c
#   shm
#   shm.c
#   sleepers-awake.c
no changes added to commit (use "git add" and/or "git commit -a")
$

したがって、正規表現 (グロブ?) を機能させることができます。*/binまた、 inを使用してテストを再実行しました (最初のテストをクリーンアップした後) .gitignore。同じ結果 — パターンが機能し、ディレクトリが抑制されました。

git --versionレポートを使用して Mac OS X 10.9 (Mavericks) でテスト済み1.8.3.4 (Apple Git-47)

于 2013-11-07T17:44:12.873 に答える