# Reverting a specific commit

5 messages from 2010-09-23 to 2010-09-23. Participants: milindkanchan, John Tapsell, Pascal Obry.
Thread: https://gitlist.dev/t/25206

## milindkanchan, 2010-09-23 07:13

Subject: Reverting a specific commit
Message-ID: <1285226023268-5561992.post@n2.nabble.com>
URL: https://gitlist.dev/e/1285226023268-5561992.post%40n2.nabble.com

```

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, 2010-09-23 07:17

Subject: Re: Reverting a specific commit
Message-ID: <AANLkTikB2A99zXvp8kyajkT63y3HuPMKyTgDg+HJUCLN@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTikB2A99zXvp8kyajkT63y3HuPMKyTgDg%2BHJUCLN%40mail.gmail.com
In-Reply-To: <1285226023268-5561992.post@n2.nabble.com>

```
On 23 September 2010 08:13, milindkanchan <milindkanchan@gmail.com> wrote:
>
> 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, 2010-09-23 07:17

Subject: Re: Reverting a specific commit
Message-ID: <AANLkTi=8gfw3FbReaCmf=tVnu2CEajCLmW-7whn27cya@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3D8gfw3FbReaCmf%3DtVnu2CEajCLmW-7whn27cya%40mail.gmail.com
In-Reply-To: <1285226023268-5561992.post@n2.nabble.com>

```
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, 2010-09-23 08:01

Subject: Re: Reverting a specific commit
Message-ID: <1285228861635-5562096.post@n2.nabble.com>
URL: https://gitlist.dev/e/1285228861635-5562096.post%40n2.nabble.com
In-Reply-To: <AANLkTi=8gfw3FbReaCmf=tVnu2CEajCLmW-7whn27cya@mail.gmail.com>

```

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, 2010-09-23 09:05

Subject: Re: Reverting a specific commit
Message-ID: <AANLkTinogubdAZkA272ryG9qr9D=T5H9PwHPth3ThoQ9@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTinogubdAZkA272ryG9qr9D%3DT5H9PwHPth3ThoQ9%40mail.gmail.com
In-Reply-To: <1285228861635-5562096.post@n2.nabble.com>

```
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

```
