0

I am using git and currently on the master branch. I did some changes to files in my working directory but would like to delete those changes and go back to the version of the project when the last commit was make.

I tried git checkout master but that gives a list of files when "M" on the start of each line and "Already on 'master'" message. But changed files are not being re changed back to how they were at the time of the last commit.

How can I got back to how the project was in the last commit? Thanks

edit
This question is different in that I want to undo the changes in the working directory to match the last commit in the repository.
Where the suggested duplicate post was not about that but rather it is about undo changes that were committed to the repository.

Fred J.
  • 5,759
  • 10
  • 57
  • 106
  • Possible duplicate of [How do you undo the last commit?](http://stackoverflow.com/questions/927358/how-do-you-undo-the-last-commit) – litel Apr 03 '16 at 22:59

1 Answers1

-3

Did you pull them?

If yes, you can revert them like this:

Go to the Repo - > Pull Requests - > Closed - > Click on the last commit request - > Revert

Edit

Another one solution: How to undo last commit(s) in Git?

Community
  • 1
  • 1
Greg
  • 343
  • 3
  • 17
  • What do you mean by "pull them", I am using the command line, Sorry I am having hard time understanding what you mean. – Fred J. Apr 03 '16 at 22:53
  • Git is working like this: Firstly you make the changes local, then you commit them in your branch and after you make a pull request to the working/master branch. – Greg Apr 03 '16 at 22:55
  • Are you saying do $git pull on the command line? I could not find this in the [Git docs](http://gitref.org/index.html) It seams to me that you think I am using a GUI for git which is not the case. And there is not commit that I want to undo, I just want to change my working directory to match what's in the repository in the last commit – Fred J. Apr 03 '16 at 22:58
  • if you are or if you are not using a GUI, its another story. You have always to do `git pull` from command or even from GUI for merging your commit into your working brach. – Greg Apr 03 '16 at 23:01
  • You wrote: "I am using git and currently on the master branch. I did some changes to files in my working directory but would like to **delete those changes** and **go back** to the version of the project when the **last commit was make**." Obviously from this statement, someone can understand that you want to **undo your last commit** – Greg Apr 03 '16 at 23:03
  • If you do not want to **undo your last commit**, rephrase your question. It doesn't make any sense with your last comment here. – Greg Apr 03 '16 at 23:06
  • but I want to keep my last commit. and undo the differences between it and the working directory so that when I do git status there would be no red files indicating any differences. – Fred J. Apr 03 '16 at 23:11
  • But if you are going to commit "changed" files, git status will always flag as red the changed files. To be clear, you want to ignore the changes from your commit ? – Greg Apr 03 '16 at 23:13
  • You can always keep a backup from the repo as it is right now, and after to revert the changes of your last commit. And then to check the differences manually. – Greg Apr 03 '16 at 23:16
  • Also, are you sure that webStore pushed the changes from the master branch ? Are you sure that you did a pull from working to master branch ? Fix first of all your issue that webStore doesn't see your changes. – Greg Apr 03 '16 at 23:25