jgit - How do I add an unchanged file to git index -


i writing tool has keep history of (generated) files in git repository.

one of requests must able take whatever generated in specific commit , replay branch.

on surface, looks cherry-picking, there nuances make little bit different.

each commit generates set of files working tree. files may exist in working tree, , quite often, generated content unchanged version in working tree.

at later time, must able take list of files generated previous commit (regardless whether content changed or not) , copy branch.

my first question is: can add file git index (and commit) if content has not changed?

if have muck around git internals that, still okay. need sure not break git repo other git tools.

i using java , open source jgit library interacting git repository, second question is, if possible in jgit

if yes, api pointers appreciated.

thanks.

to answer explicit question - if file existed in previous commit, , content has not changed @ (although metadata may have), file in index. after commit, index contains exact contents of commit. adding/deleting changes makes appropriate modifications index prepare next commit. counter couple other answers/comments, git not store changes - stores complete snapshots of working directory (or @ least non-ignored, not-untracked parts of it). calculates changes when ask to, not store them (at least git front-end perspective - underlying object database use deltas reduce amount of space required, deltas uses may not between consecutive versions of file, , may not between 2 versions of same file if have files similar).

to answer sounds wanting do, might want research git reset --merge. if that's not quite want, can this, change current working directory match specific commit, , commit state new commit - copying snapshot represented source commit, on different branch or possibly earlier in current branch, , making new commit looks it, except considered parent commit:

git rm -r * git archive --format=tar <commit> | tar xpf - git add -a . git commit -m "snapshot copy of commit <commit>" 

you use git archive --format=zip <commit> -o /tmp/somefile.zip; unzip /tmp/somefile.zip well, prefer use tar format since can pipe it...


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -