While using git, we all have our code in our own repository, pushing to and pulling from a bare repository.
If I need parts of the newest code in a specific folder for later use by an automated script, what would be the best way to get the code from the personal repository to that specific folder? (Is there a "git way" of doing this?)
Thank you.
CodePudding user response:
The solution to my problem: Not using a bare repository. I thought, that I have to use the bare repo to push etc. BUT...
As I learned, I can just create a normal repository with git init
and after that execute the command:
git config --global receive.denyCurrentBranch updateInstead
This opens the repository up AND the repository will be able store all our changes at one place. Now just add it as remote and et voilà.
CodePudding user response:
Git only
If you only want to rely exclusively on Git features, a combination of a post-recive
server-side hook combined with an external worktree
at the location where your automated script expects to find the updated scripts.
Rough sketch:
- Set up the worktree at the location on the server where your BI-tools want to read them.
- Add a server-side hook that updates that worktree, roughly like shown in the worktree example:
pushd ../worktree git checkout -f <main-or-other-branch-to-follow> popd
Github
If your bare git repo is actually hosted on Github or a local Gitlab instance, you might have the benefit of using Github Actions or Gitlab CI pipelines. For just this action, both mechanisms introduce much baggage, but scale much better to much more automation around your development, especially increased visibility (you see which actions were triggered by event).