Git: Fix sha1 resolving when a branch is added from detached HEAD

Change-Id: I0d8ad988411256fc284b84f78be6f54362ab19ea
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>