0

I have a file that has a variable that points to API which is in the local system.

There are 3 developers and every time we pull we have to change the variable back to our respective IP.

This is a tracked file and I read that gitignore won't ignore tracked files. So I did what this answer said: https://stackoverflow.com/a/23673910/5599387

But every time I pull I get:

Your local changes to the following files would be overwritten by merge: Please commit your changes or stash them before you merge. Aborting

How do I not commit any changes made to that file by any developer

Le guy
  • 59
  • 8
  • Which local changes do you have? Also, untracking the file has to be done on every branches, I suspect that what you try to pull contains changes to the file. – padawin Apr 04 '19 at 08:44
  • @padawin i get that even when i dont have any local changes – Le guy Apr 04 '19 at 08:48
  • I had similar issue, i just stashed changes using: `git stash save`, and after pulling, just `git stash pop`, but i guess there is a better solution.. – Aaron_ab Apr 04 '19 at 08:48
  • Why do you want to ignore tracked files? What's the actual problem you're trying to solve? – evolutionxbox Apr 04 '19 at 08:49
  • @evolutionxbox the file has a variable that points to API which is their local system. every time a developer pulls, he has to change that variable to point to their local system.. – Le guy Apr 04 '19 at 08:52
  • https://stackoverflow.com/questions/1974886/how-to-version-control-config-files-pragmatically – phd Apr 04 '19 at 09:09
  • The solution of a filter with smudge and clean (using `sed`) in @phd 's comment should be able to satisfy your needs. In practise, you may encounter some issues. If the smudge does not work after the configuration, you can run `rm ;git reset --hard` to force the smudge to work. But before that, make sure you have already backed up all the uncommitted changes. If it then works, the file may get stuck in a changed state. Run `git add ` to fix the wrong state. – ElpieKay Apr 04 '19 at 09:46

1 Answers1

2

I perhaps have a non-git solution.

If it is doable, you can change your variable so that it takes the IP from an environment variable. So the file can be the same for everybody and each dev can set the environment variable with the needed value. So it would look as follow (pseudo code, as I don't know which language you use):

hostIP = get_from_env("HOST_IP");

That would however not answer the current issue with Git, more the underlying problem.

And the change has to be done for everybody, so that everybody are in sync.

padawin
  • 4,230
  • 15
  • 19