-2

What is the meaning of original commit in git?
Is it refer to the commit of the last pull?
I want to reset to the last commit of the server that I obtained by git pull. So I have read that git reset --hard return to the original commit, but I'm not sure that it means the last commit that I have got from server.

HadiMohammadi
  • 133
  • 3
  • 8
  • 1
    Possible duplicate of [How to undo the most recent commits in Git?](https://stackoverflow.com/questions/927358/how-to-undo-the-most-recent-commits-in-git) – Daniel Jan 23 '18 at 02:09

2 Answers2

0

If you wanna rollback to the commit SHA you run git pull, try following which should always does the trick.

git reset --hard <remote>/<branch> 

Say your remote names origin and you're on feature branch, that will be git reset --hard origin/feature. Afaik, there's no conventional meaning of so called original commit.

Allen
  • 4,431
  • 2
  • 27
  • 39
0

In that context "original commit" is the most recent commit on your current branch (assuming you're on a branch).

git reset --hard by-itself will reset your current un-committed work. So any files you have edited since the last commit will return to the state they they were in on the most recent commit on that branch. It will not reset to the state of the remote unless that is the most recent commit.

           git reset --hard <commit>
           Resets the index and working tree. Any changes to tracked files in
           the working tree since <commit> are discarded.

In place of commit you can pass anything that refers to a commit.

A few examples:

  • git reset --hard HEAD~n = resets the last n commits on your current branch
  • git reset --hard branchX # make my current branch look like branchX
  • git reset --hard origin/master # reset to the point when this branch diverges from the remote branch origin/master

See also Daniel's link: How to undo the most recent commits in Git?

tgf
  • 2,977
  • 2
  • 18
  • 29