Re: All my commits disappeared after Repo-sync

628 views
Skip to first unread message

Magnus Bäck

unread,
Nov 29, 2012, 9:38:38 AM11/29/12
to repo-d...@googlegroups.com
On Thursday, November 29, 2012 at 02:18 EST,
David <retb...@gmail.com> wrote:

> All my commits(saved in local) disappeared after repo-sync. I dunno why,
> but I checked using "gitk"..and everything disappeared!
> How can I restore those things?

The problem is that you started working without creating a topic branch
with "repo start". If you don't do that, you'll be working on a detached
head and your changes won't be available after a sync.

To get your commits back, run "git reflog" to obtain the SHA-1 or
symbolic name of your most recent commit. It's probably the second line
of output (i.e. HEAD@{1}). Then you can run this to restore:

repo start mybranch .
git reset --hard HEAD@{1}
repo sync -l .

So, this creates a new topic branch, resets it back to the state where
it would've been prior to your last sync, and finally runs a local-only
sync that'll rebase the branch onto the current upstream tip.

[...]

--
Magnus Bäck
ba...@google.com

gunjan mehta

unread,
May 22, 2015, 2:39:21 PM5/22/15
to repo-d...@googlegroups.com, ba...@google.com
Saved my day...
Thanks Magnus!!
Reply all
Reply to author
Forward
0 new messages