When Your Mate Deletes Your Files On A Common Project

What happens when your friend removes some of your files because he thought it was not needed and then you want to rebase and it is gone. There are several ways to recover the file, by going to github and checking on its history, but here I will present two methods of how to do this. The first one is via a log command and the second is via a rev-list command.

git log --pretty=oneline -- <file_path> | tac

This way we reverse the output of a git log regarding the file in question. But now let’s look at a more interesting way:

git rev-list -n 1 HEAD -- <file_path>
git checkout <deleting_commit>^ -- <file_path>
// or in one command
git checkout $(git rev-list -n 1 HEAD -- "$file")^ -- "$file"

source: http://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo
In case you also want to review more than one commit you can vary the 1 above to include more commits that have to do with the file in question.

Git Subtree Split: This is what Symfony2 does every night to set standalone Components!

First we need to get the git-subtree project:

~ git clone git@github.com:cordoval/git-subtree.git
~ sudo apt-get install asciidoc
~ sudo make install
~ sudo ./install // just to be sure :D

Now that our tool to do the job is installed it is time to filter all the commits and create our new repository, push to github and then add prehaps a composer to it that can in turn require the other dependency of Config Component.

~ git subtree split -P src/Symfony/Component/ResourceWatcher
ec140481b9e7b7f18aa10516f5da6e43bbaea47a
~ git checkout ec140481b9e7b7f18aa10516f5da6e43bbaea47a
~ git checkout -b component/resourceWatcher
// from here on you can push to github.com

Now our component is ready to be sourced from any project’s composer.json. Just remember to include also the Config component dependency.
You can find my personal repo at https://github.com/cordoval/ResourceWatcher.

Update: Thanks to @Stof for this link http://help.github.com/split-a-subpath-into-a-new-repo/
They do it this way which makes a lot more sense :D and perhaps more git learning oriented:

[tekkub@tekBook: ~/tmp/github-gem master] $ git filter-branch --prune-empty --subdirectory-filter lib master