4

Say I have a staging area that has some additional files necessary for the staging area, that I don't want in my repository. Nor do I want to actually include those ignore patterns in the shared .gitignore file.

Ideal what I'd like to do is have a kind of "local only" .gitignore for just that environment, in addition to the shared .gitignore. Is that possible to do?

1
  • 1
    If your staging area is in a separate directory, you can just put a .gitignore in that directory - it doesn't have to be at project root. Commented May 22, 2016 at 3:50

1 Answer 1

5

Yes, you can use:

$GIT_DIR/info/exclude .git/info/exclude 

It is local to the repo, and won't be pushed.
It works for untracked files.

The other approach to ignore files (already versioned) temporarily would be

git update-index --skip-worktree -- [<file>...] 
Sign up to request clarification or add additional context in comments.

3 Comments

Since .gitignore has a higher precedence, I'm afraid this cannot work.
@ElpieKay Why? If those additional files are not in the local .gitignore, they will be ignored by the exclude file.
Don't forget git config core.excludesFile (usually set with --global, but can technically be set per-repo), which defaults to $XDG_CONFIG_HOME/git/ignore

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.