开发者

Problem with ignoring a directory in git

I've seen many posts on SO about this but none of the solutions I've tried work.

I have a directory structure as follows

MySite\Bin
MySite\Obj
MySite\Important

My .gitignore file which is at the root is (and yes I've tried removing the * also)

MySite\bin\*
MySite\obj\*

Executing the command git status show开发者_JAVA百科s this

#       modified:   .gitignore
#       modified:   SomeOtherFile.fle
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       MySite/bin/
#       MySite/obj/

I've tried executing the following commands

git rm -r MySite\bin
git rm -r --cached MySite\bin

git rm MySite\bin\fileToIgnore.dll
git rm --cached MySite\bin\fileToIgnore.dll

And I keep getting this error fatal: pathspec 'MySite/bin' did not match any files

When executing git add . the files in MySite\Bin and MySite\obj are added to the staging items. Why?

I'm also using the windows version of git (mysysgit).

Many thanks!


You have your slashes in the wrong order.

MySite/bin
MySite/obj

According to the docs of gitignore it is a pattern. And Git path pattern always follows unix path names with forward slashes.

Do that and it should work.


Not to point out the obvious, but you have Bin and bin. (Note case). I believe git is case sensitive no matter the platform.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜