1

I have a local working copy of a git repo, and it needs to have some changes in order to work for local testing, but I don't want those changes to be sent to remote when I do add --all and commit.

Basically the files are:

/protected/config/*
/protected/components/UserIdentity.php

I tried adding those into .git/info/exclude, but git status still shows the changes (which are already made to the files).

I need the files to stay in the remote, but locally they must be changed and immune to eg. pull.

Is there a way?

MightyPork
  • 18,270
  • 10
  • 79
  • 133
  • Third answer in the linked question might be of most interest to you. – poke May 05 '15 at 06:27
  • I don't see a point in marking this as duplicate since the linked question is quite a bit different and I already received the relevant answer here too – MightyPork May 05 '15 at 06:31

1 Answers1

1

The author of this site proposes a solution:

git update-index --assume-unchanged <file>

Will ignore local modifications on tracked files and

git update-index --no-assume-unchanged <file>

will undo the previous command. This work even with git commit --all as assumed-unchanged files are not staged.

Reading git-update-index man-page you can also see that this bit is not reset after you committed, so you either have to --no-assume-unchanged the file/path or do a git update-index --really-refresh to get every modification back.

If merging with something (branch/tag/commit) (for example when doing a git pull) which has modifications in that file, you will get a

error: Your local changes to the following files would be overwritten by merge:

error and the merge is aborted.

So, no, it won't work with git-pull, if there are modifications upstream.

Patrick B.
  • 11,773
  • 8
  • 58
  • 101