Back to TILs.

Calmcode TIL

Running Git from Another Folder logoRunning Git from Another Folder

I have little cron-server that runs scraping jobs. Some of these jobs need to populate git-repos. Once a file is downloaded it needs to be moved into a folder that has git after which it is merged.

It turns out, thankfully, that you’re able to run git commands from another folder.

Here’s the syntax.

git -C <folder> <commands>

Makefile commands

In my case that means that I have a Makefile with the following command in it.

    mv data.csv project_folder
    git -C project_folder status
    git -C project_folder add data.csv
    git -C project_folder commit -m new-data
    git -C project_folder push origin main

Quite convenient!

Back to TILs.