threads / discuss / 25206

Reverting a specific commit

Subject: Reverting a specific commit

## tl;dr

5 messages between Sep 23, 2010 and Sep 23, 2010.

replies: 4people: 3as markdown or json

milindkanchan· Sep 23, 2010, 07:13 UTC · lore
Hi All,
I am using git for code management.
I have some query regarding reverting the commit in git.
Can we revert a specific commit in git ?

Eg. One of our X developer has committed the code in master branch last week, after which there were several commits to master branch, now there was an issue with the code committed by X developer and now I need to revert/discard just his commit keeping the other commits done after him as intact.

Can anybody give a solution for this with all the commands.

Thanks & Regard M.K

-- 
View this message in context: http://git.661346.n2.nabble.com/Reverting-a-specific-commit-tp5561992p5561992.html
Sent from the git mailing list archive at Nabble.com.
John Tapsell· Sep 23, 2010, 07:17 UTC · re: milindkanchan · lore

Re: Reverting a specific commit

On 23 September 2010 08:13, milindkanchan <milindkanchan@gmail.com> wrote:
Show 8 quoted lines
>
> Hi All,
>
> I am using git for code management.
>
> I have some query regarding reverting the commit in git.
>
> Can we revert a specific commit in git ?
To make a new commit to undo a bad commit:
git revert SHA

where SHA is that long string of numbers and letters associated with each commit. do "git log" to find out what the SHA is.

John
Pascal Obry· Sep 23, 2010, 07:17 UTC · re: milindkanchan · lore

Re: Reverting a specific commit

On Thu, Sep 23, 2010 at 9:13 AM, milindkanchan <milindkanchan@gmail.com> wrote:
> Can we revert a specific commit in git ?
   $ git revert <sha1>
for more information:
   $ git revert --help
Pascal.
-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
milindkanchan· Sep 23, 2010, 08:01 UTC · re: Pascal Obry · lore

Re: Reverting a specific commit

But will it affect the commits done after that
-- 
View this message in context: http://git.661346.n2.nabble.com/Reverting-a-specific-commit-tp5561992p5562096.html
Sent from the git mailing list archive at Nabble.com.
Pascal Obry· Sep 23, 2010, 09:05 UTC · re: milindkanchan · lore

Re: Reverting a specific commit

On Thu, Sep 23, 2010 at 10:01 AM, milindkanchan <milindkanchan@gmail.com> wrote:
>
> But will it affect the commits done after that

No. It is a revert. I will create a new commit that revert the work done for the given commit.

Pascal.
-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595

← back to recent threads