1

I have a script I'm using from my repo's root and I don't want it to appear each time I git status.

I thought of adding it to .gitignore but I don't want this change tracked because I don't want the master's .gitignore to contain this file path (as no one else has it).

Is it possible to gitignore this file in a way my gitignore wouldn't be uploaded when, for example, I git commit -a?

CIsForCookies
  • 12,097
  • 11
  • 59
  • 124
  • Note that `git commit -a` *won't* add existing untracked files anyway. You only need to list the file to stop `git add .` or similar from adding it. – torek Feb 11 '19 at 11:12
  • I'm not afraid of the file itself. My concern is the gitignore content that would be commited – CIsForCookies Feb 11 '19 at 11:20
  • Sure, but my point is, if you're adding entries to some sort of ignore file to avoid `git commit -a` adding those files, you're adding them needlessly, since `git commit -a` never adds new files, and listing tracked files has no effect. This means your additional ignore file has no effect as the only files it can affect are those that are (a) not listed in the existing `.gitignore` and (b) untracked, and *those* files are never going to be added by `git commit -a`. – torek Feb 11 '19 at 11:22
  • But, that's why all of this is just a comment: it's the fact that `git commit -a` is not a good example here. Ignoring the files *is* useful with `git status`, and of course also with `git add`. So `.git/info/exclude` is the way to go. – torek Feb 11 '19 at 11:24

2 Answers2

3

You can use .git/info/exclude to have your non shared ignore rules.

See this SO answer When would you use .git/info/exclude instead of .gitignore to exclude files?

And the docu: https://git-scm.com/docs/gitignore

RedX
  • 14,749
  • 1
  • 53
  • 76
3

Create a .git/info/exclude file and put the file path there. The syntax is identical to .gitignore file, but the file local to your repo.

1615903
  • 32,635
  • 12
  • 70
  • 99