less common git techniques
I’ve had to solve some interesting problems over the last few weeks, and although it doesn’t really surprise me, git has come to the rescue in every single case.
Merging two git repositories
Say you were working on a spike of some independent code in its’ own repo, and you’ve decided you want to merge it into your main repository. Easy:
http://nuclearsquid.com/writings/subtree-merging-and-you/
Triggering TeamCity builds directly from github
GitHub is awesome. You should host your code there. But triggering your local build without polling them every 30 seconds? No problem:
http://www.jaxzin.com/2011/02/teamcity-build-triggering-by-github.html
Splitting a git repository (including history)
Finally, imagine a folder that you’d love to get rid of out of your repository. Hypothetically, let’s say a folder full of documentation, specifications, Word files, Visio files and the like. Hundreds of megs and you don’t really need that shit in a codebase do you? Well, let’s split it out:
http://stackoverflow.com/questions/359424/detach-subdirectory-into-separate-git-repository
// copy your repo to a new directory
git clone --no-hardlinks ./original_repo ./new_repo
// now filter out the folder(s) you want to keep
cd new_repo/
git status
git filter-branch --subdirectory-filter ./the_folder_you_want_to_split/ HEAD
git reset --hard
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --aggressive --prune=now// and head back to the original repo and delete that folder
cd ../original_repo/
git filter-branch --index-filter "git rm -r -f --cached --ignore-unmatch the_folder_you_want_to_split" --prune-empty HEAD
git reset --hard
git gc --aggressive --prune=now
And one for the road, here’s a cool little site that outlines what goes on under git’s covers:
I did have a few free ebooks on the topic, I’ll see if I can dig them up - they are great reads.
-
jaxzin liked this
-
mwjackson posted this