0

I want to mark a file to be ignored when I push to the remote repo. The idea is to use it with some files that I will change locally but almost never want to push those changes. e.g. a settings file where I add local test settings. If someone else makes change to the file (usually the architect) then I want to get those on my next fetch/pull and am happy for those to overwrite my local changes.

I have tried putting the file in .git\info\exclude but this does not give me what I want. It ignores the file and gives me errors when I try to switch branch.

Paul McCarthy
  • 818
  • 9
  • 24
  • **Exactly** what text are you putting into the `.git\info\exclude` file? (Absolute paths? Repo-root relative paths? Glob paths? etc) – Dai Feb 06 '20 at 14:13
  • just the name of the file to ignore – Paul McCarthy Feb 06 '20 at 14:15
  • 2
    Does this answer your question? [How do I configure git to ignore some files locally?](https://stackoverflow.com/questions/1753070/how-do-i-configure-git-to-ignore-some-files-locally) – Michele Dorigatti Feb 06 '20 at 14:20
  • Generally speaking, if you need to modify tracked files _at all_ locally - the question to ask (yourself) is: how do I restructure my app so I don't need to modify tracked files? – AD7six Feb 06 '20 at 14:22
  • The "git update-index --skip-worktree FILENAME" on the suggested similar question looks to be what I am looking for. – Paul McCarthy Feb 06 '20 at 14:33

1 Answers1

2

Try to add to .gitignore relative path to file you want to exclude For example, your repo looks like

.git
.gitignore
|
|---dir1
    |
    file1

.gitignore contains

dir1/file1