Removing unattached file and directories with git / info / exclude

git version 1.7.11.7 Fedora 17 

Hello,

I am creating a new working resposity git

 git init 

I have added some files and some directories.

However, I have some files that I want to ignore based on my environment. I do not want to create a .gitignore file, because I do not want it to be added to the repository. Just my local one.

So, I want to ignore my server/build directory, so I added it to the .git/info/exclude file.

 # exclude patterns (uncomment them if you want to use them): *.[oa] *~ server/build 

server is the root directory in which I initialize my git repository.

However, when I execute git status, I always get this directory in my unverified files.

 # On branch dev # Untracked files: # (use "git add <file>..." to include in what will be committed) # server/build/ 

I want to remove this from my git state.

I tried the following: did not work for me

 git rm -r --cached server/build 
+4
source share
1 answer

You leave a space before the pattern. Remove it and it should work:

 # exclude patterns (uncomment them if you want to use them): *.[oa] *~ server/build 

If your repo does not have .gitignore , you can create it yourself and ignore it, but in reality it is still correct to use exclude .

+5
source

Source: https://habr.com/ru/post/1446857/


All Articles