On Sun, Feb 2, 2014 at 11:29 AM, Valerio Pachera <siri...@gmail.com> wrote:

> Consider a very simple example: two files:
> one.txt
> two.txt
> then content of each file is just 'first line'.
> git init
> git commit -m 'initial commit'
> Then I add a second line to the first file.
> I fake a mistake writing '2 line' inside the file.
> Then
> git add one.txt
> git commit -m 'added second line file one.txt'
> The I add the second line to file two.txt "correctly"
> 'second line'.
> Then
> git add two.txt
> git commit -m 'added second line file two.txt'
> Now I notice the mistake I made in the previous commit.
> I wisht to fix '2 line' with 'second line'.
> I can't use 'git commit --amend' because it will affect the last commit.
> Ho do I manage to correct the commit 'added second line file one.txt'
> without issuing another commit?
> Considering that:
> - these commits has not yet been "merged" by other users
> - the amend scope is to fix a trivial error

Hi Valerio,

it's pretty well explained in this page :

I'd never done it before so I tried it on my own.

For the example you described, you can :

`git rebase -i HEAD~2`

Then in the text editor, replace 'pick' with 'edit' at the line
corresponding to the commit containing the error, save.

Then make your correction in the one.txt file, `git add` it, `git commit

`git rebase --continue`

and you're done.


You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to