1

I want to undo on selected commit. Cause my team push different many files and many commits.

What I did was pull with deleted files. now my files gone also.

I tried this

git rebase -i 4dd0c29
git reset --hard undo

but nothings changed

Storm Spirit
  • 1,440
  • 4
  • 19
  • 42
  • Check this ones : http://stackoverflow.com/questions/20324638/reverting-specific-commits-from-git http://stackoverflow.com/questions/2938301/remove-specific-commit More : https://www.git-tower.com/learn/git/faq/restore-repo-to-previous-revision – Mayur Prajapati Aug 01 '16 at 11:24
  • Read this it will explain how to do it. http://stackoverflow.com/questions/34519665/how-to-move-head-back-to-a-previous-location-detached-head/34519716#34519716 – CodeWizard Aug 01 '16 at 11:31

3 Answers3

1

To revert a specific commit, use git revert <commit>

This will create a new commit where the content of <commit> has been reverted.

Martin G
  • 17,357
  • 9
  • 82
  • 98
1

Use command git log in project's main git directory to get recent commits. Most recent commit will be shown up first. It will also log commit number in long format. For example:

commit ed7cec151e25ea7f9e0d0563598ee9afd3170952
Author: xxx <xxx@email.com>
Date:   Thu Jul 28 17:25:51 2016 +0500

Then hard reset all changes using your commit ID:

git reset --hard ed7cec151e25ea7f9e0d0563598ee9afd3170952

Hope it helps.

NightFury
  • 13,436
  • 6
  • 71
  • 120
0

Use git reflog it will give you a list with log of the activities which changed HEAD. Find HEAD@{id} (where id is a number) which indicates at the head prior to git pull and then do git reset --hard HEAD@{id} (make sure replacing word id with the number of the HEAD)

Alternatively, you can do git reset --hard HEAD^ this will revert your HEAD to previous state it was in prior to git pull.

e.doroskevic
  • 2,129
  • 18
  • 25