Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reset to a specific commit?

I have the following recent commits when I do "git log --oneline"...I want to reset to "8ec2027",I tried some rebase commands that didnot work..what is the exact command to do this?

2503013 code: cs release 1.2.3.47
269ed14 code: Fixed below issues due to which 2nd client is not associating to GO
dca02a3 code: Donot allow the scan during WPS/EAPOL exchange.
b2fee57 code: MCC Adaptive Scheduler
6af29c4 code: Not able to connect more then 10 STA
150aacd code: Fix the Max Tx power value in 5G band and .ini support for 11h
8ec2027 Merge "code: cs release 1.2.3.46"
9015b60 Merge "code: Quarky Support on Prima"
......
like image 926
user1934146 Avatar asked Jan 14 '13 07:01

user1934146


People also ask

How do I reset a specific commit in origin?

Make sure you are on the branch where the commit is. I'm doing this on master. Then use git reset –hard <commit-hash> to set the current branch HEAD to the commit you want.

Can you revert specific commit?

You can revert a specific commit to remove its changes from your branch. When you revert to a previous commit, the revert is also a commit. The original commit also remains in the repository's history.

How do you reset hard to a commit?

To hard reset files to HEAD on Git, use the “git reset” command with the “–hard” option and specify the HEAD. The purpose of the “git reset” command is to move the current HEAD to the commit specified (in this case, the HEAD itself, one commit before HEAD and so on).


2 Answers

You want to reset not rebase. Rebasing is the act of replaying commits. Resetting is making the current commit some other one.

you will need to save any work that you may have in your work directory first:

 git stash -u

then you will make you current commit the one you want with

git reset --hard 8ec2027

Optionally, after you can save where you were before doing this with:

git branch -b temp HEAD@{1}

see reflog documentation to see how this works.

like image 177
Adam Dymitruk Avatar answered Sep 30 '22 20:09

Adam Dymitruk


Probably this could also work out for you

  1. Create a new branch at 2503013 (this saves the changes after 8ec202)

  2. git reset --hard 8ec2027

like image 45
Evgeny Avatar answered Sep 30 '22 22:09

Evgeny