Last Updated: February 25, 2016
·
624
· jai

Create google code review for the initial commit in a new git repo

While there could be other cleaner ways of doing it. Michal Cihar tipped on http://stackoverflow.com/questions/14564034/creating-a-git-diff-from-nothing that was useful for me.

Do the following

git checkout --orphan empty         # Create orphaned branch
rm .git/index                       # Remove all files from index
git commit --allow-empty -m 'Empty' # Initial commit

Now you can do full diff against empty branch:

git diff empty..master

Now if you use upload.py (https://code.google.com/p/rietveld/wiki/UploadPyUsage) for sending code reviews to the server, use the following command now.

upload.py --rev=empty..master

Delete the empty repo after the review is done.

git checkout master
git branch -D empty