Synchronizing one file between two Git repos

I ran into a trivial situation, but it looks like it doesn't have a simple solution: I want to sync one config file between two repositories git

. It can be a one-way interaction: the origin is stored in the project A

and tracked within the projectB

I know the concept git submodule

, but submodulating a large repository into a smaller one for just one file seems overkill.

+3


source to share


2 answers


You can just add one repo as remote and checkout.
Then you can checkout the file from another branch (including remote tracking )

git remote add repoA A
git fetch repoA
git checkout repoA/master -- file

      



(Suppose you want a file from A

to repo B

)

+3


source


If both repos are stored on the same machine,



  • Save the file in the A

    repo project . Where his history is written.
  • Place a link to the file in the B

    repo project .
  • Add a link to B

    .gitignore

    .
+2


source







All Articles