3

I have 3 git repositories:

  • local: my development repo on my local machine;
  • remote1 used for collaboration with other developers;
  • remote2 which is a Production server.

    1. I would like to pull regularly from remote1 to my local repo and keep some local tracked files intact (i.e. fetch and merge from remote1, but exclude some local tracked files from being merged).

    2. On the other side, I would like to regularly push to remote2 and I would like local tracked files to be pushed as well.

In other words, I would like to have the following versions of file1:

  • local: file1 v.1
  • remote1: file1, v.2
  • remote2: file1, v.1

Note: file1 can be anything (.css, .html, even .png)

I have tried the following approaches:

  • .gitignore a file (does not work, the file becomes being tracked again after pull from remote1)
  • git pull --no-ff --no-commit remote1 master, then git checkout --ours file1 according to this (does not work, file1 becomes v.2)
  • .git/info/exclude as described here (does not work, nothing is ignored and even if it is ignored, file1 will not be pushed to remote2 then)
Community
  • 1
  • 1
skanatek
  • 5,133
  • 3
  • 47
  • 75

1 Answers1

1

You could try to a:

  • git update-index --assume-unchanged -- path/to/file1 before pulling from remote1, and
  • git update-index --no-assume-unchanged -- path/to/file1 just after pulling from remote1.

(If that doesn't work, try also git update-index --skip-worktree)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Could you please elaborate? What does this command do underneath? Is it possible to push in the same manner? – skanatek Jul 10 '13 at 15:09
  • @MartinLee http://stackoverflow.com/a/13631525/6309. You can remove that option before pushing. – VonC Jul 10 '13 at 16:56