Skip to content

Git’s coolest merge ever for research collaborations

March 23, 2012

The coolest research groups in the world maintain a git repo where all their research papers, code and documentation is stored and versioned. Some groups keep these repos private, at least during the period when the paper is being written. The problem is: cool research groups collaborate with other cool research groups. Two groups would like to write a paper together, and share private access to that paper, but no access to the other papers. One way to do that is to use a service like BitBucket, which offers free private repos. Both groups would then have access to this fresh BitBucket repo for the writing period, and when they are done, both can merge the changes in with their internal private repo. This kind of merge, preserving the changes history, and everything, is known as  “the coolest merge ever“. I found about it on StackOverflow, and I’ve done it already for two papers. Very cute!

See the recipe below:

cd ~/CoolResearchGroup/PrivateGitRepo/                             # this is where you keep your clone of the group's repo
git remote add other ~/BitBucket/PrivateGitRepoForCollaboration    # this is where you keep your clone of the private repo
git fetch other
git checkout -b PrivateGitRepoForCollaboration other/master
mkdir PrivateGitRepoForCollaboration
git mv *.tex PrivateGitRepoForCollaboration           # move the files that you need
git checkout master                                   # should add new branch to master
git commit
git remote rm other                                   # don't need the temporary branch anymore
git push                                              # if you have a remote, that is
Advertisements

From → tech-tips

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: