1

Here is my commits from assembla

when I do git log

nothing to commit, working directory clean
Secret-MacBook-Air:q-sort judyngai$ git log
commit bcab1e2ea50b4ce427d64d20f748c5b64a0d08b3
Author: secret <secret@gmail.com>
Date:   Sat Feb 8 19:39:01 2014 -0500

    Revert "restoring t_c"

    This reverts commit d95c6427869a6924358112a2b6c1d87dc29faa38.

commit cef4c538beeeec37287d57f2b78e7f89412c57e6
Author: Secret <secret@gmail.com>
Date:   Sat Feb 8 19:38:51 2014 -0500

    Revert "Revert "restoring t_c""

    This reverts commit 3c61d17b71ae5017cf364a83c664f0b77603700b.

commit 3c61d17b71ae5017cf364a83c664f0b77603700b
Author: Secret <secret@gmail.com>
Date:   Sat Feb 8 19:35:38 2014 -0500

    Revert "restoring t_c"

    This reverts commit d95c6427869a6924358112a2b6c1d87dc29faa38.

commit d95c6427869a6924358112a2b6c1d87dc29faa38
Author: Secret <secret@gmail.com>
Date:   Sat Feb 8 19:34:44 2014 -0500

    restoring t_c
    Revert "moved to better traco version and added specific load path to config/init/local.rb"

    This reverts commit 202ca306b0076c77748c9d3d0845506a529ab767.

commit 202ca306b0076c77748c9d3d0845506a529ab767
Author: Secret <secret@gmail.com>
Date:   Sat Feb 8 18:17:40 2014 -0500

    moved to better traco version and added specific load path to config/init/local.rb

commit a745f3e353d28b3170f5f30849c9ab31cf35e795
Author: Secret <secret@gmail.com>
Date:   Sat Feb 8 16:00:19 2014 -0500

    removed translatable_column fear clash with traco

commit 634537e267c9035b201060131ae0467f0891a233
Author: Secret <secret@gmail.com>
Date:   Sat Feb 8 15:34:42 2014 -0500

    downgraded traco to be compatible with 1.8.8

commit 5908ea1388d16a2665f90533405e70b1d4c343de
Author: Secret<secret@gmail.com>
Date:   Sat Feb 8 15:05:48 2014 -0500

    trying traco instead of translatable_column

commit 0e0db6404246fd9e239183da437e5bd0a4235ca1
Author: Secret <secret@gmail.com>
Date:   Fri Feb 7 17:30:35 2014 -0500

    uninstalled pg

I want to go back permanently to my last commit from the log that I posted. I was replacing an old gem with a new gem and it didn't work out. I know there has been tons of answers for something like this but whenever I tried

git revert commit1 commit2 commit3

I will end up in a detached head?

I have tried

git reset --hard committhatIwanttoreturnto

but its only a temp solution and I will be behind many commits.

I tried to checkout the first commit then revert back

did

git revert HEAD

twice and ended up reverting my reverting. because I figured I can revert one by one?

Jngai1297
  • 2,415
  • 5
  • 29
  • 63
  • "I want to go back permanently to my last commit from the log that I posted" <-- meaning? What SHA1 do you want? – fge Feb 09 '14 at 00:50
  • Regarding "I will end up in a detached head?": Revert does not detach HEAD; if you're in a "detached HEAD" situation after a revert, you were in one before you started. You then said "I tried to checkout the first commit": you probably *did* check it out, and *that's* what resulted in the "detached HEAD". – torek Feb 09 '14 at 00:58
  • @fge its this one, commit 0e0db6404246fd9e239183da437e5bd0a4235ca1 – Jngai1297 Feb 09 '14 at 03:25

1 Answers1

1

If you don't want to git push --force after your reset --hard, you simply can make a new commit which will look like 'committhatIwanttoreturnto', as in "Revert multiple git commits":

Make sure you are on the right branch first (ie the one which includes those revert commit and committhatIwanttoreturnto)

$ git checkout theRightBranch

$ git reset --hard committhatIwanttoreturnto
$ git reset --soft @{1}  # (or ORIG_HEAD)
$ git commit -a

That will create a new commit on top of your current branch which will have the exact content of 'committhatIwanttoreturnto'.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This is the (well, "a") correct answer, assuming one does this while on the target branch of course; but I think the original poster is rather lost in the forest of branches and HEAD and so on. :-) – torek Feb 09 '14 at 01:00
  • @torek It is possible. I have added in the answer the need to checkout a branch first. – VonC Feb 09 '14 at 01:06