Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ignore folders using .gitignore? [duplicate]

Tags:

How can I ignore directories or folders in Git using msysgit on Windows?

like image 777
sf. Avatar asked Dec 05 '08 12:12

sf.


People also ask

Can Gitignore ignore folders?

gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .

Does Gitignore work in subfolders?

gitignore file is usually placed in the repository's root directory. However, you can create multiple . gitignore files in different subdirectories in your repository.

How do I exclude folders from git repository?

Open the . git/info/exclude file in a text editor and add the folder to ignore. This file remains private to you.

Does Gitignore get cloned?

The process of cloning ignores the . gitignore file. If a file is added, committed and another commit with the . gitignore is created, the file will still be part of the repository and therefore cloned.


2 Answers

Create a file named .gitignore in your project's directory. Ignore directories by entering the directory name into the file (with a slash appended):

dir_to_ignore/ 

More information is here.

like image 164
stew Avatar answered Sep 21 '22 15:09

stew


By default, Windows Explorer will display .gitignore when in fact the file name is .gitignore.txt.

Git will not use .gitignore.txt

And you can't rename the file to .gitignore, because Windows Explorer thinks it's a file of type gitignore without a name.

Non command line solution:

You can rename a file to ".gitignore.", and it will create ".gitignore"
like image 27
brainwavedave Avatar answered Sep 18 '22 15:09

brainwavedave