3

I have only one problem with git, and it is that I have the .gitignore is trying to be added in the repo, but i don't want it to be, and how do you ignore the ignore file? I don't ever want to see .gitignore anywhere.

I have tried to ignore it, but i can only discard it or remove it, and that is definitely not what i want to do.

enter image description here

Samuel Thompson
  • 2,429
  • 4
  • 24
  • 34

2 Answers2

5

To maintain a list of files to ignore, that is not part of your repository, don't use the .gitignore file. Instead, edit .git/info/exclude, which won't ever get added to the repository.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • This is the correct answer. I'd just add that those 2 files serve different purposes. It's common practice to fill '.gitignore' with project generated files/directories, like build output. While '.git/info/exclude' is useful to ignore files specific to the developer machine or configuration – arainone Jan 07 '16 at 07:53
  • is there a way to do this without actually modifying the file myself? for example right click a file, and then select exclude? – Samuel Thompson Jan 07 '16 at 20:25
  • @SamuelThompson: That would be a feature of the GUI you're using, in your case SourceTree. I'm afraid I don't know much about SourceTree. – Greg Hewgill Jan 07 '16 at 20:42
  • what GUI would you suggest? – Samuel Thompson Jan 08 '16 at 18:33
  • @SamuelThompson: I don't use a GUI for Git, I use it from the command line. So I'm afraid I don't have a GUI to suggest. I would edit the `.git/info/exclude` file manually. – Greg Hewgill Jan 08 '16 at 19:50
2

Why wont you want it in your repo?
This file should be there.

Anyway, You should use the assume-unchanged flag
https://git-scm.com/docs/git-update-index

--[no-]assume-unchanged

When this flag is specified, the object names recorded for the paths are not updated.
Instead, this option sets/unsets the "assume unchanged" bit for the paths.

When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).

Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.

enter image description here

CodeWizard
  • 128,036
  • 21
  • 144
  • 167