1

I'm searching on the internet how to "git pull without modifying specific files", but I'm going in circles and getting lost.

This is the scenario, I have some configuration files, let's say one of them is called C and in this file there is my local path for some reasons while in the same file, but on the machines of my colleagues, it has their file paths. So C contains as much different states as the total number of the colleagues in our working group.

In order to use C locally on each of our machine we executed git update-index --assume-unchanged ..path-to-C../C so that, whenever one of us makes a push, that specific file won't be taken in consideration. In other words, if I understood correctly, C won't be updated in the repo on git even if we make local changes on it. In this way everyone of us can put their file path in it.

But that's only half of the problem solved.

Now what I want to do is to tell to git "I don't want you to modify in any way my local C while I'm doing a pull".

How do I get this result?

I don't want to use the .gitignore because by the tests we made we saw some behaviors that we don't want to happen. For example if my colleague puts C in the .gitignore and makes a push, when I do a pull my C won't be present in my local repo. So everytime I make a pull I will have to put C manually inside my project to get it working.

This is due to the fact that to make it work we do the following combination of commands:

git rm --cached ..path-to-C../C

move C to the .gitignore (with intellij .ignore plugin)

from intellij mark it as a file to be untracked

The result of this is that Intellij highlights our file with a yellow color in order to say "hey this file is officially untracked".

What I want is to automate this part of the process by marking in some way the file like I did for the push but for the pull in this case.

config.err
  • 41
  • 1
  • 6
  • 1
    https://stackoverflow.com/a/1733921/341994 – matt Nov 12 '20 at 11:46
  • You can use the stash as a workaround and make command line aliases that use this workaround. Then use these aliases instead of the regular pull/push – miva2 Nov 12 '20 at 12:40
  • Note that if file `C` exists in commits and in Git's index (which is filled in *from* commits), listing file `C` in a `.gitignore` literally has no effect at all. So the mention of `.gitignore` is irrelevant here. What really matters is that `git update-index --assume-unchanged` trick. – torek Nov 13 '20 at 01:18
  • The important thing is that uncommitted changes to file `C` will interfere with merges that *do* have changes to file `C`. Remember that `git pull` means *run `git fetch`, then run a second Git command*. That second Git command is `git merge` by default. You can change the choice of second command but your other option—`git rebase`—is no help here. The problem is file `C` itself. Don't do it this way. – torek Nov 13 '20 at 01:20
  • If you're, er, committed (if you'll pardon the word choice) to doing it this way anyway, well, now you must deal with the problem. That's pretty much all there is to it. – torek Nov 13 '20 at 01:20
  • @torek sorry torek I didn't explain very well the process followed with the .gitignore approach, now I've edited the question hope the process it's more clear – config.err Nov 13 '20 at 08:53

0 Answers0