I am in a git repo where I messed up a few things I want to revert it to same state as in the morning , I remember there is a command to do it but not able to find that, Can anyone please help? Thanks
Asked
Active
Viewed 1,001 times
0
-
Does this solve your problem: https://stackoverflow.com/q/4114095/11074646 ? – Ankit Kumar Jul 02 '20 at 18:41
-
Does this answer your question? [How do I revert a Git repository to a previous commit?](https://stackoverflow.com/questions/4114095/how-do-i-revert-a-git-repository-to-a-previous-commit) – Paolo Jul 02 '20 at 18:45
-
I want to go to a state in morning , I dont really know what is last commit at that time, So i want a git command to take the repo to previous state using time (like to a state before 3 hours) – Jul 02 '20 at 18:51
2 Answers
1
You can checkout to the commit id, after which you have messed things up. That will detach your HEAD. After that, you can create a new branch from there and proceed.
This answer might help you with more detailed explanation --> https://stackoverflow.com/a/4114122/13852431

himayan
- 784
- 3
- 9
-
Problem is I dont know last commit because i pulled code after that , so i want command to take repo to previous state using time – Jul 02 '20 at 18:53
-
```git checkout `git rev-list -1 --before="Jul 02 2020" master``` This one can detach your head to a commit at some date, but I am not sure about time level precision here. Reference - https://www.endpoint.com/blog/2014/05/19/git-checkout-at-specific-date – himayan Jul 02 '20 at 19:01