On this server I host several git repositories, and sometimes I want to add update a single file in a large repository.
It would be quite convenient if I could just update the bare repository without doing a checkout (it saves on space, no trouble with outdated repositories etc)
Obviously, someone on the internet already had asked the same question.
I just put it in a nice script, with a simple test to ensure it works :)
You can download the script called git-bare-add, and view the source of the script below.
Usage is quite simple:
git bare-add [-b $BRANCH] $BARE-REPO $REL-PATH $NEW-ABS-FILE $COMMIT-MSG
$BARE-REPO is the path to the bare repository,
$REL-PATH the path to the file inside the repository that should be updated.
$NEW-ABS-FILE is the absolute filepath to the file that should be copied to
$REL-PATH inside the repository.
$COMMIT-MSG is (obviously) the commit message.
One can also edit a file in place, by using the option
--edit and dropping the
git bare-add --edit [-b $BRANCH] $BARE-REPO $REL-PATH $COMMIT-MSG
To perform some tests:
git bare-add --test
It should be relatively safe to use this script, since it makes use of git porcelain stuff.
Note that there is no safety regarding multiple simultaneous accesses.
Thus it is best used on a repository where you are for sure the only writer (during the whole length of the edit), since I think it will ignore commits made while edits are being made.