March 2012
84 posts
Nostalgia Attack!!
- Brian: i'm on the phone with this one guy, he's using joomla, he keeps referring to it as jamba
- Brian: now i want a fruit smoothie
- Evan: well, also because clojure will make you incurably insane.
- Me: functionally insane thank you very much. little to no side-effects
- Evan: hahaha. I prefer "immutably insane" then.
- Me: Why is everyone scared to talk to me?
- Dallas: I don't know. I just imagine that when you're in an interview you start screaming: BUBBLE SORT NOW!!!!!
- Me: ....
- Me: let's create a non-mainstream band, sell out, make millions and still wear tight jeans
- Brian: yes, let's analyze the BPM of the top 40 songs over the last 6 months, analyze the key they were written in, do some lexical analysis on lyrics and start with a strong foundation.
- Brian: music; like an engineer
- Me: Let's call ourselves "Lexical Robot"
- Brian: DONE!
- Me: I think I'm going to start doing hardware hacks
- Me: SOFTWARE BORES ME NOW
- Brian: YOU MUST GO DEEPER
- Me: TWIDDLE MY BITS
And I want my last words to be if I die from it…”it was delicious”
Fuck you, Dark Souls.
(┛◉Д◉)┛彡┻━┻
Recently, I needed to do some repository splitting using git. Originally, I figured this would be a long and laborious process that I would curse for years to come. So let me start this off with this: It wasn’t that bad.
I googled quite a bit and found this fantastic StackOverflow post about it. I needed to do something a little different than what was done here so I’ll walk you guys through the whole process.
So let’s say you have a git repository laid out as follows:
proj1/
best_app_ever.php
tests/
old_project/
ABC/
ABC.php
Let’s say you want to move the directory ABC and ABC.php from the project above because proj1 has just become too big and place it into a new project called proj2.
Step 1: Clone your repository as proj2
git clone proj1 proj2
Optional: Remove your origin. I do this just so I don’t accidentally remove anything from the origin.
git remote rm origin
Step 2: Filter the history out you don’t want.
git filter-branch --index-filter "git rm -rf best_app_ever.php tests old_project" --prune-empty -- --all
Here is where I start to diverge from the StackOverflow post, I don’t want to just extract out ABC, I want ABC.php as well. Using —subdirectory-filter just won’t cut it here. We use index-filter to rewrite the index and run the command git remove command on the files I don’t want. The prune-empty flag will trim the commits that are empty that occurred while executing your filter. It’s important to note that —all will rewrite all branches and tags.
Step 3: Reset the index and working tree
git reset --hard
Step 4: Clean up all your refs
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
This goes through all the refs and deletes them if they contain an old value.
Step 5: Expire all the old reflog entries
git reflog expire --expire=now --all
Step 6: Clean up and optimize, pruning anything older than now.
git gc --aggressive --prune=now
The above steps should create two different repositories with all history preserved!
proj1/
best_app_ever.php
tests/
old_project/
proj2/
ABC/
ABC.php
Hope this helps you the next time you need to split up a repository!
Recently, I wanted to see what files in a commit changed over here at Tumblr so that we could do some syntax checking.
So I needed to basically see all the files that changed on a merge commit that happened with 2 parents. The following command pulls out all the php files from that merge commit.
git show --pretty="format:" --name-only parent1...parent2 | grep .php | sort | uniq
With this one liner, I have a list of all the different files that changed in the commit, ready to be lint checked. Neat, huh? Git is awesome.
February 2012
45 posts
(╯°□°)╯︵ ┻━┻