Using git subtree to clone a subdirectory of a project with versioning history then merge it back af

Posted by D W on Stack Overflow See other posts from Stack Overflow or by D W
Published on 2010-03-23T21:37:27Z Indexed on 2010/03/23 21:43 UTC
Read the original article Hit count: 854

Filed under:
|
|
|
|

I am a graduate student with many scripts, bibliography data in bibtex, thesis draft in latex, presentations in open office, posters in scribus, and figures and result data. I would like to put everything in one project under version control. Then when I need to work on a portion such as the bibliography data, I would like to check that subdirectory out, modify it as necessary and merge it back.I would like the ability to check out one version to my home computer, and a different one to my work computer and make changes to each independently and eventually merge them back. I would also like to be able to check out a piece of code from this big project and import it with versioning into a separate project. If I may changes I'd like to be able to merge them back to the original project.

Based on my understanding git subtree can do this.

http://github.com/apenwarr/git-subtree

There is an example that is along the lines of what I'm trying to do at:

http://psionides.jogger.pl/2010/02/04/sharing-code-between-projects-with-git-subtree/

This code is from that site:

git clone git://git2.kernel.org/pub/scm/git/git.git
newtree=$(git subtree split --prefix=gitweb --annotate='(split) ' \
       0a8f4f0^.. --onto=1130ef3 --rejoin)
git branch latest_gitweb $newtree
gitk latest_gitweb

Say the trunk of my project contained the directories: (bib bin cfg data fig src todo). How would I use git-subtree to split off the bib (bibliography) directory with versioning?

When I use

git-subtree split --prefix=bib

I get

884842f6f4e9896e2e4e9402ee0ef762cd617257

as output, but I don't know where to go from there.

© Stack Overflow or respective owner

Related posts about git

Related posts about subtree