Dylan Kinnett wrote:
> I hope this group is a good place to ask questions like this. I'm new to
> version control, but I'm quickly finding Git to be a great way to manage my
> collection of writings. I do have a question, though. I have, for example,
> a repository that contains 200 .txt files. Each one is the text of a poem.
> Now, I'd like to set aside 20 of those files, for example, to create a
> manuscript. While I'm working with those 20 files and thinking of them as a
> group, I may make changes to them. I would like, of course, for those
> changes to be reflected in my "master" repository of all 200 files, as well
> as within the smaller group. Is there a way to manage such a thing with a
> Git branch? As I understand it, a branch is typically for working with a
> copy of all the files. Would it work for what I have in mind, if the branch
> only contains a sub-set of those files?

The difficulty in using a branch for this is that when you merge such a
branch back into master, git will see you are merging a change that
deleted all the other files, and so will remove them from master.

Here's one way around it:

joey@darkstar:~/tmp/demo>perl -e 'open(OUT,">",$_) for 1..100'; git add . ; git 
commit -m add
joey@darkstar:~/tmp/demo>git rm 2* 3* 4* 5* 6* 7* 8* 9*
joey@darkstar:~/tmp/demo>git commit -m 'prep smallbranch'
joey@darkstar:~/tmp/demo>git revert HEAD -m 'still want all files in master 
joey@darkstar:~/tmp/demo>git checkout HEAD^ -b smallbranch
Switched to a new branch 'smallbranch'
1  10  100  11  12  13  14  15  16  17  18  19
joey@darkstar:~/tmp/demo#smallbranch>echo "work work work" >> 1
joey@darkstar:~/tmp/demo#smallbranch>git commit -m "worked in smallbranch" -a
Merge made by the 'recursive' strategy.
 1 | 1 +
 1 file changed, 1 insertion(+)

The other way to do it is to make smallbranch start as a completely
disconnected line of development from master, so merging it in does not
involve any commit that deletes files in master. While this should work
perfectly well, I don't think that git porcelain makes it easy to create
such a branch. (But it would not be hard to use plumbing to add a git
command that creates such a branch containing an arbitrary subset of
files from the current branch.)

see shy jo

Attachment: signature.asc
Description: Digital signature

vcs-home mailing list

Reply via email to