In this scenario, a Git Repo has been exported, and the contents of the repo deployed onto an environment.
This deployment does not have any knowledge of Git.
Initialise a new git repo, so any changes can be tracked.
git init
git add .
git commit -am "initial commit"
You can now make your changes, then we commit them as usual. Let's say we make 2 commits for this patch.
echo 'hello world' > test-file
git add test-file
git commit -m "test commit"
echo 'some test' > another-test-file
git add another-test-file
git commit -m "added another file"
Then we create the patches for these 2 commits
git format-patch -2
This will create 2 patch files.
Copy the patch files onto the machine with your actual git repo, then apply them like this
git apply 0001-test-commit.patch
git diff # review changes
git add test-file
git commit -m "applied patch commit 1"
git apply 0002-added-another-file.patch
git diff # review changes
git add another-test-file
git commit -m "applied patch commit 2"
I am going to try this and I hope this helps some people.
I made a folder with a simple README.md. I made the changes above
After initializing the repository I change the root branch from master to main.
Here is the git CLI and a folder where I was just after the step "git format-patch -2"


Here is the text of the patch file: 0001-test-commit.patch

Here is the text of the patch file: 0002-added-another-file.patch

Here is the git status in the CLI

I applied the first patch with:
I got an error

Trying just the line "git apply 0001-test-commit.patch" produces the error.
