Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using .gitignore to not commit bin, debug and config folders

Tags:

git

gitignore

I’m using git in my ASP.NET MVC project.

I want no files from debug, bin or config folder to show in the “Pending Chages” dialog so I will not have to commit them to my repository.

These files are machine specific specially the config folder.

I tried to add the following to .gitignore:

myproject\bin**
myproject\obj**
myproject\config\**

This did not work because all files under all three folders are still displayed after each build or config changes.

What am I doing wrong?

like image 722
Mortalus Avatar asked Dec 01 '12 09:12

Mortalus


People also ask

Can Gitignore ignore a folder?

Inside . gitignore , you can tell Git to ignore only a single file or a single folder by mentioning the name or pattern of that specific file or folder. You can also tell Git to ignore multiple files or folders using the same method.

How do I ignore obj and bin folder in Git?

While the sdk create the bin and obj folder, if it create a . gitignore with * as content, git will automatically ignore the content of this folder.

Should Gitignore files be committed?

There is no explicit git ignore command: instead the .gitignore file must be edited and committed by hand when you have new files that you wish to ignore. . gitignore files contain patterns that are matched against file names in your repository to determine whether or not they should be ignored.

Can you commit files in Gitignore?

gitignore file is up-to-date and contains all the correct patterns you want to ignore. Commit or stash any outstanding local changes you might have. Your working copy should be clean before you continue.


1 Answers

Remove the ** from the dir name (also, I use forward slashes, don't know if that makes a difference).

Remember to remove all the offending files that might be in your repository already. A delete and commit should take care of it.

Also, if you have multiple projects you can get all bins ignored by not putting the project name in front. This should work:

bin
obj
config

This looks like the definitive SO answer: How do I ignore files in a directory in Git?

like image 97
mcalex Avatar answered Oct 30 '22 19:10

mcalex