Synchronizing single file between two Git repos

I faced with a trivial situation but it seems like it have no simple solution: I want to synchronize a single config file between two git repositories. It even could be a one-way interaction: origin is stored in project A and is tracked inside project B

I’m aware of git submodule concept, but submoduling of the large repository in the smaller one only for the sake of a single file seems to be overkill.

  • Another git process seems to be running in this repository
  • How do I replace a corrupt file using a git repository?
  • Any git hook to block merge conflict?
  • An exception occurred while creating local git repository -Openshift
  • Git/GitHub: Do I checkout remote branches from origin or upstream?
  • Conditional Gitignore
  • How do I git rebase the first commit?
  • Rollback using repo command?
  • git gui branch management
  • Can you develop directly in Git submodules?
  • How to open the project from GitHub in Android studio? Troubles with Maven and android support libraries.
  • Fork repo for a single folder
  • 2 Solutions collect form web for “Synchronizing single file between two Git repos”

    You could simply add one repo as a remote and fetch.
    Then you can checkout a file from another branch (including a remote tracking one)

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

    (Assuming you want the file from A into repo B)

    If both repos are kept on the same machine;

    • Keep the file in the project A repo. There is where its history is recorded.
    • Put a link to the file in project B‘s repo.
    • Add that link to B‘s .gitignore.
    Git Baby is a git and github fan, let's start git clone.