1

I messed up when publishing a project in React and now my master branch's other projects are gone. I can't seem to figure out how to?

My Github page: https://github.com/guillherme6/guillherme6.github.io

I'm using:

git revert 19512552f7d7829c241e82a6b8b730624f956996

and

git revert 1951255

What am I doing wrong?

randominstanceOfLivingThing
  • 16,873
  • 13
  • 49
  • 72
  • Please add some more text in . post – RIYAJ KHAN Feb 15 '18 at 04:28
  • Possible duplicate [How to revert Git repository to a previous commit?](https://stackoverflow.com/questions/4114095/how-to-revert-git-repository-to-a-previous-commit) – Mayank Shukla Feb 15 '18 at 04:28
  • What isn't working exactly? What do you want to accomplish? Git defines "revert" with a specific meaning. What happens when you issue the command? Do you get an error? If so, what is it? If not how do the results differ from what you want. – Code-Apprentice Feb 15 '18 at 05:36
  • I'm trying to restore what my repository looked like before I pushed a React App and deleted everything in my master branch.. – Guillherme06 Feb 15 '18 at 19:03

2 Answers2

1

if you want to revert a commit from your git stack, you can do those following.

  1. if you want to revert the commit but, not lose the changes you can type

git reset --soft HEAD@{index of the commit}

  1. if you want to delete the commit from your git stack

git reset --hard HEAD~index of the commit

Just one thing. if you want to use those commands, you should know that it removes from the first commit until the commit you'll assign. that means if you want to remove git reset --hard HEAD~2 it will remove from commit index 1 until commit index 2.

Of course, also you can use git revert but is the same pattern. you'd type the index commit from your head stack

example to revert to two commits prior

git revert HEAD~2

monkey intern
  • 705
  • 3
  • 14
  • 34
Kenry Sanchez
  • 1,703
  • 2
  • 18
  • 24
  • Please note, that any reset on your history will change your history which will result in conflicts if you have a published history. – ckruczek Feb 15 '18 at 06:47
  • (psst, git doesn't use stacks, but directed acyclic graphs... I'm just being pedantic wooo) – evolutionxbox Feb 15 '18 at 08:57
  • with a stack, i mean the list of commits in your local branch. and yes, any reset will change your history but I think is a good practice for not handle commits unnecessaries – Kenry Sanchez Feb 15 '18 at 14:05
0

If you want to an specific commit do git checkout 19512552f7d7829c241e82a6b8b730624f956996

Sergio Rivas
  • 543
  • 3
  • 9