0

My mentor and I are both working on a project in Visual Studio 2017 -directly in the master branch. (using GitHub for Visual Studio extension).

I recently pulled in his changes (3 commits) but now i want to go back to the state I was in, before pulling the changes.

I searched about git revert, git reset etc. but they seem to make changes to the branch in git.

I want to go back to the previous version of my code - only on my local machine, without disturbing the repository on GitHub. Any way to restore the code to a certain point in the tree, locally, without changing the tree itself?

I do not hold much experience in this, Thanks.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
  • 2
    Possible duplicate of [Go to particular revision](https://stackoverflow.com/questions/7539130/go-to-particular-revision) – mkrieger1 Jul 13 '19 at 09:45
  • 2
    As long as you don't push, your local state stays local. Do whatever you want locally, it won't impact the github repo unless you decide to push. – Romain Valeri Jul 13 '19 at 12:35

1 Answers1

0

Your question does not provide enough information of the purpose of 'restoring the code to a certain point'.

  • if that is just temporary to test a specific behavior or see the look of the code, have a look at git checkout <sha1_of_a_commit>.

And when you've finished, don't forget to return to the master branch with git checkout master

  • if that's because you realized that didn't want to pull the commits from the remote, do a git reset --hard <sha1_of_a_commit> after taking care of having stashed all the uncommitted changes.

And don't be afraid, you can't mess the remote commits until you 'force pushed' which is not advised until you understand what you are doing!

Philippe
  • 28,207
  • 6
  • 54
  • 78