0

I created a github repo for some scripts I use in order to keep from having to remote into the server every time I want to make a change.

This code needs to exist simultaneously on two different servers, and one of the servers doesn't need all of the files that the other one does.

Is it possible for me to sync a repo over two different servers each having their own gitignore files?

iNeedScissors61
  • 191
  • 1
  • 4
  • 16

1 Answers1

1

It's possible to have different exclude information on both servers [1]. However with that said, this won't stop a pushed file from being downloaded on the server that has that file excluded. There is no way to stop git from pulling all files when you pull.

You would need to have two repositories if you have different files, or use some sort of submodule approach for shared files (repoA and repoB go to serverA and serverB, and both include a shared submodule repoShared) - but this is now really pushing what is already a non-ideal use case for git.


[1]:

Git stores exclude information in $GIT_DIR/info/exclude (where $GIT_DIR is your .git folder within you repository), so you could hardcode relevant files in there.

Note, if you already have unstaged changes you must run the following after editing your ignore-patterns:

git update-index --assume-unchanged [<file>...]

See the relevant documentation, or previous posts on similar matter.

th3ant
  • 328
  • 1
  • 9