How do i quickly revert back from a commit in git?
-
git man page: http://bit.ly/2nvGNWB
I modified my README.md file and added a Sixth line but it'a duplicate and I want to get it back to a previous commit, which I know to be how I want my git repository to be in.
Below shows my Sixth line added.
$ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: README.md no changes added to commit (use "git add" and/or "git commit -a") $ git diff diff --git a/README.md b/README.md index 9f28333..10d8f68 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,5 @@ Third Line: I got straight to bed Fourth Line: and I dream of running the marathon Fifth Line: but I don't dress up in a silly costume I'm a serious runner + +Sixth Line: Today i woke up and went running $ cat README.md First Line: Today i woke up and went running Second Line: When I get back from running I'm tired Third Line: I got straight to bed Fourth Line: and I dream of running the marathon Fifth Line: but I don't dress up in a silly costume I'm a serious runner Sixth Line: Today i woke up and went running To get it back to the last required commit, then an easy way is to run a git reset, with options --hard. ```bash $ git reset --hard HEAD is now at 091ffd1 My commit of the fifth line again $ cat README.md First Line: Today i woke up and went running Second Line: When I get back from running I'm tired Third Line: I got straight to bed Fourth Line: and I dream of running the marathon Fifth Line: but I don't dress up in a silly costume I'm a serious runner
© Lightnetics 2024