3

我有 3 个 git 存储库:

  • local:我在本地机器上的开发仓库;
  • remote1用于与其他开发者协作;
  • remote2这是一个生产服务器。

    1. 我想pull定期从remote1我的仓库中local取出并保持一些本地跟踪文件完好无损(即从 获取和合并remote1,但排除一些本地跟踪文件被合并)。

    2. 另一方面,我想定期push推送remote2本地跟踪文件。

换句话说,我想要以下版本file1

  • local:文件1 v.1
  • remote1:文件1,v.2
  • remote2:文件1,v.1

注意:file1可以是任何东西(.css、.html,甚至 .png)

我尝试了以下方法:

  • .gitignore一个文件(不起作用,从 拉取后该文件再次被跟踪remote1
  • git pull --no-ff --no-commit remote1 master,然后git checkout --ours file1按照这个(不行,file1变成v.2)
  • .git/info/exclude如此处所述(不起作用,什么都不会被忽略,即使它被忽略,file1也不会被推送到remote2那时)
4

1 回答 1

1

您可以尝试:

  • git update-index --assume-unchanged -- path/to/file1 拉出之前remote1,和
  • git update-index --no-assume-unchanged -- path/to/file1刚从remote1.

(如果这不起作用,请尝试git update-index --skip-worktree

于 2013-07-03T06:57:44.243 回答