Adding things to a git bare repository -
i know if have files in bare repository, can access them using git show head:path/to/file
.
but can add new content bare repository without cloning , modifying working tree?
if add 1 file, 1 file in commit, aka added new , it's set in stone
there's several convenient ways add single-file commit tip of master branch in bare repo.
so appears need create blob object, attach tree, attach tree object commit.
all ways commit boil down doing that, it's question of how convenience commands suit purpose. git add
creates blob , makes entry in index; git commit
git write-tree
adds new trees what's in index, , git commit-tree
adds commit of top-level resulting tree, , git update-ref
keep head
date. bare repos have head
commit, attached (aka symbolic ref for) branch master
, . . .
so git's convenience commands doing want. 1 file, going easy.
say example files appear in ~server/data/logs/
, bare repo you're using distribution @ ~server/repo.git
, want committed files @ data/logs
in repo, , want commit latest logfile:
#!/bin/sh cd ~server # supply locations git ordinarily on own in working i.e. non-bare repos: export git_dir=$pwd/repo.git # bare repos don't have defaults these export git_work_tree=$pwd # supply suit our purpose export git_index_file=$git_dir/scratch-index # ... # payload: commit (only) latest file in data/logs: git read-tree --empty # make index pretty, , git add data/logs/`ls -1t data/logs|sed q` # everything's ordinary here - add , git commit -m'new logfile' # commit
git read-tree
loads index entries committed trees. it's underlies checkout , merge , reset , others i'm forgetting atm. here, want empty index start, hence --empty
.
use push/pull/remote synchronize data while using tool available on every machine
you said "millions" of files on time, , if don't want full history distributed, rsync
gather suspect might better bet. -- 1 @ time, 1 new file per minute, it'll take 2 years accumulate 1 million. so, ?
whatever, above procedure pretty efficiently extensible small-ish numbers of files per commit. bulk work there better ways.
Comments
Post a Comment