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.I would like to
pull
regularly fromremote1
to mylocal
repo and keep some local tracked files intact (i.e. fetch and merge fromremote1
, but exclude some local tracked files from being merged).On the other side, I would like to regularly
push
toremote2
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.1remote1
: file1, v.2remote2
: 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 fromremote1
)git pull --no-ff --no-commit remote1 master
, thengit 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 toremote2
then)