1

I am not entirely sure what this feature is called, so I am just going to describe it, and perhaps someone can tell me how to do this.

I have a git repo called mySettings where I store my settings for various editors like Sublime.

Currently I am manually copying files between my local system and that repo, and then pushing them to the repo.

What I would ideally want is some sort of link between my local files and the repo so that every time I run say git add . --all && git commit -m 'updated local files' && git push it automagically pulls in all my local files that I have linked to that repo.

An example:

Say on my local system I have ~/FancyEditor/User/superbSettings and I have my fancy repo ~/mySettings/ then if I were to run the above git add . --all && git commit -m 'updated local files' && git push inside ~/mySettings it then has some form of link to ~/FancyEditor/User/superbSettings thus relieving me of having to copy it to that repo every time I want to back it up.

Astrid
  • 1,690
  • 4
  • 25
  • 44

1 Answers1

1

One of the best way is to use the symlinks. But currently git doesn't support using symlink files as a normal file, see: How does git handle symbolic links?.

So the best way to do this is using the git hooks. just create a hook to execute the commands to copy the contents of the required files to the repository folder replacing the existing files. See the git hooks manual: https://git-scm.com/book/uz/v2/Customizing-Git-Git-Hooks

Example command:

cp -rf ~/FancyEditor/User/superbSettings ~/mySettings

See this too: Run script before commit and include the update in this commit?

Community
  • 1
  • 1
Gautam Krishna R
  • 2,090
  • 20
  • 26