Search code examples
gitandroid-sourcerepository

repo/git revert to state as one month ago


I'm working with AOSP sources which were downloaded by repo command (http://source.android.com/source/using-repo.html)

Now I need to get all repository as it was 1 month ago.
I found here solution (http://alexpeattie.com/blog/working-with-dates-in-git/):
git revert master@{"1 month ago"}

But I can't do it in AOSP source tree.
I tried to do it with:
repo forall -c git revert master@{"1 month ago"}
But it's not working because there is no master branch for all git repositories in AOSP repo.

Is there any solution?


Solution

  • first of all, find the commit hash you want to revert to :

    git log --pretty=oneline --since="2013-08-26"
    

    you can change the date if you want

    you'll get all commit from this date to today the last one in the list will be the one you want

    Then :

    git reset --hard 0845f5de..... // this need to be the hash you got previously
    

    Hard will change your working directory and your index to the version of the commit while moving the current branch to this commit

    Use it precautionously !!! You will loose your current change to the working directory