Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git excludes vs ignores

I use Tower for using Git in Mac. The settings in Tower has Ignores section which creates the .gitignore, but it has another section named "Excludes". And it seems like that one can use excludes with "# git ls-files --others --exclude-from=.git/info/exclude".

Tower screenshot

What Excludes is for? Why one needs excludes when gitignore is available?

like image 209
prosseek Avatar asked Apr 08 '12 21:04

prosseek


People also ask

What is the difference between Gitignore and exclude?

git/info/exclude is the same as . gitignore, just a lower precedence and not in the repository (so, not committed and shared). Neither affects already tracked files. Both affect files that are not currently tracked.

What is git exclude?

gitignore file is a text file that tells Git which files or folders to ignore in a project. A local . gitignore file is usually placed in the root directory of a project. You can also create a global . gitignore file and any entries in that file will be ignored in all of your Git repositories.

What files should be ignored in git?

Ignored files are usually build artifacts and machine generated files that can be derived from your repository source or should otherwise not be committed. Some common examples are: dependency caches, such as the contents of /node_modules or /packages. compiled code, such as .o , .

How do you exclude or ignore some files from git commit?

Set “–assume-unchanged” to a path to exclude to check on git commit and it will exclude your file from git commit. You will need to use the git update-index and –assume-unchanged to exclude files from git commit.


1 Answers

It's a list of files that are not in .gitignore (which can be versioned), but which you want to exclude on your machine's copy of the repo.

From the docs:

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user's workflow) should go into the $GIT_DIR/info/exclude file.

Note that .git/info/exclude can not be versioned because it's in the .git directory.

like image 121
Matthew Flaschen Avatar answered Sep 23 '22 12:09

Matthew Flaschen