2011-01-26 1 views
0

私はプロジェクトのためにgitを使用し、例えばパスから特定のサブフォルダが、そのフォルダのない兄弟を除外したいのです:gitignoreファイルでLookahead/Lookbehindを否定するにはどうすればよいですか?

/Testpath/TestpathA 
/Testpath/TestpathB 
/Testpath/TestpathC 

私はTestpathAおよびC(および可能性のある他のパスを無視したいですこれらのフォルダの兄弟であることではなく、私は

/Testpath/* 
!/Testpath/TestpathB 

を試みたが、それはうまくいきませんでした

TestpathB。

I lso試しました /Testpath /(?! TestpathB)/ *

しかし、それも動作しませんでした。

+0

を私はあなたのタグを変更 - gitignoresは、正規表現を使用しないでください。彼らはグロビングの特定の風味を使用します。 – Cascabel

答えて

0

Testpath/* 
!Testpath/TestpathB 

編集:実際には、あなたの例は私にとってもうまく機能します。あなたは何をしているのですか? .gitignoreの作成以外に、実行しているコマンドは何ですか?

/Testpath/* 
!/Testpath/TestpathB 

を使用して

+0

@ Nemo157 これは問題なく動作していたようです。 TestPath/TestpathB/* これはうまくいきませんでしたが、フォルダ全体が否定されるようにしました。 – indigo0086

0

は私のために働いた:

→ cat .gitignore 
/Testpath/* 
!/Testpath/TestpathB 

→ tree 
. 
└── Testpath 
    ├── TestpathA 
    │   └── testfile 
    ├── TestpathB 
    │   └── testfile 
    └── TestpathC 
     └── testfile 

4 directories, 3 files 

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

→ git add . 

→ git status 
# On branch master 
# 
# Initial commit 
# 
# Changes to be committed: 
# (use "git rm --cached <file>..." to unstage) 
# 
#  new file: .gitignore 
#  new file: Testpath/TestpathB/testfile 
# 
+0

私は先導的なパスがフォルダを無視すると思いますルートと再帰的にディレクトリツリーの下にない – indigo0086

+0

@ indigo0086:あなたが正しいと思う、私はそれを追加し、それはまだ働いた。テストの結果を投稿しました。 – Nemo157

+0

テストのおかげで、それは私のために働いただけで、それはポストに書き込むが、私は実際に何をしていたのではない。 – indigo0086

関連する問題