0

I'm collaborating with a friend on a website and wanted to update something, but now we realize that we don't want the update. So I found the commit we need, and typed

git reset --hard 0033e84…dffa6

because I found it on google, and this just replaced the changed file from back then. We want every file from back then, not just one. Then again I typed

git revert 0033e84…dffa6

and now somehow the "Last update" on the files changed, but the content is still the same new we don't want. We just want to go back. Why is that so confusing?

I only found those two command to go back, and it didn't help. The problem now is that the old commits are overwritten and its just messy.

What's the correct command to just go back in time with all the files and stuff? As it was before, not just some files.

The possible dublicate does not work in case of my problem. Whenever I want to go back, it just changes the commited FILE, not FILES in between.

  • 2
    Possible duplicate of [How to revert a Git repository to a previous commit](https://stackoverflow.com/questions/4114095/how-to-revert-a-git-repository-to-a-previous-commit) – Mateen Ulhaq Jan 21 '19 at 12:57

3 Answers3

0

Say, your branch name is b1. Then try:

$ git checkout b1

# revert the commits changes
$ git revert <from-commit-hash>..<to-commit-hash>
Sajib Khan
  • 22,878
  • 9
  • 63
  • 73
  • Hey, that just says Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. –  Jan 21 '19 at 13:49
  • But it does not change anything. I want to go back to commit 0033e84…dffa6 –  Jan 21 '19 at 13:50
  • which is like 20 commits away. Do I have to delete every commit? Some files are still the old. –  Jan 21 '19 at 13:50
  • Can you share your commit history (or, demo history) & the output what you exactly want? – Sajib Khan Jan 21 '19 at 14:38
  • It's just commits on top of each other in a master branch. Then we installed and adapt everything, but now we just want to move back. We thought to update Kirby 2 to Kirby 3, but after 10 hours fixing stuff we don't want to waste any more time with this. We want to go back before we commited the update. –  Jan 21 '19 at 15:37
  • ok, then Copy the last good commit & do `git reset --hard ` – Sajib Khan Jan 21 '19 at 15:47
0

If you typed

$ git reset --hard 0033e84…dffa6

all your file change between HEAD and this commit will back to this commit, and commit record will be discarded.

If you typed

$ git revert 0033e84…dffa6

a new commit will be created to revert the change in commit 0033e84…dffa6

As you described,I think the first command is what you need, only the files add in repository will be back, only the files change between HEAD and this commit will change.

DDK
  • 136
  • 1
  • 1
  • 11
  • I tried 'git revert 0033e84…dffa6' and it says: 'error: could not revert 0033e84... Updated page *…* hint: after resolving the conflicts, mark the corrected paths hint: with 'git add ' or 'git rm ' hint: and commit the result with 'git commit'' It seems I only change the commit from back then, but it is ignoring the commits in between –  Jan 21 '19 at 13:59
  • I don't think so.It seems somework may fail to finish from your last command,you can try to type `$ git status` to find out if any work not finish yet.It all work has been finish,type `$ git log` to know which commit you are now on. If you are in front of commit 0033e84…dffa6,then try `git reset` again – DDK Jan 21 '19 at 14:51
0

Now what I did is a new branch, then I

git reset --hard 1b2d6cb9857420892b120fcc67f528ed68435599

And it told me "HEAD is now at 1b2d6cb Commit Message" Now I was excited, because Terminal told me there is a folder, that belonged to the old version we wanted, called panel

Then I checked in my Finder, there was no folder called panel

I checked again in the Terminal via ls, and its gone again! I feel like I am using the computer for the first time. What is going on. Here a screenshot:

Terminal Screenshot