Java Afca
Java Afca

Reputation: 2237

Exclude folder from github

I need to exclude the folder App_Data from my Github but i don't know how.

I have a application which saves many files like jpg files in the directory: Source\MyProject\App_data\stored\filename.jpg

Now i need to exclude this from the .gitignore file

I don't know how to do this so i am looking for a example

Upvotes: 28

Views: 65090

Answers (4)

Dertod
Dertod

Reputation: 41

In case you need to ignore a whole folder which was already tracked, do not forget to do it recursively with -r.

  1. Add foldername/ to .gitignore

  2. git rm -r --cached foldername/

Upvotes: 2

Colonel Panic
Colonel Panic

Reputation: 137584

Per https://help.github.com/articles/ignoring-files

From time to time there are files you don't want git to track. There are a few methods of telling git what files to ignore.

If you create a file in your repository named .gitignore git will use its rules when looking at files to commit. Note that git will not ignore a file that was already tracked before a rule was added to this file to ignore it. In such a case the file must be un-tracked, usually with git rm --cached filename

This file can be committed into the repository, thus sharing the rule list with any other users that clone the repository.

Upvotes: 9

MrHappyAsthma
MrHappyAsthma

Reputation: 6522

  1. Create a file called .gitignore in your repository.
  2. Add the text "App_Data" to this file.
  3. Save.

It should do exactly what you want. It will exclude files/folders with that string from your local repository path (the path where .gitignore is stored).

Keep in mind, this is not your only option. I'd read the help document linked below for a better understanding to get exactly what you need accomplished.

See here for more info: GitHub Help - Ignoring Files

Upvotes: 37

Jon Cairns
Jon Cairns

Reputation: 11951

Simply put this in your .gitignore file (assuming MyProject is your git root):

App_data

Upvotes: 11

Related Questions