# Re: Q: howto rebase

1 messages from 2007-09-25 to 2007-09-25. Participants: lode leroy.
Thread: https://gitlist.dev/t/10014

## lode leroy, 2007-09-25 14:54

Subject: Re: Q: howto rebase
Message-ID: <b41dbf4a0709250754o189d99fcn4767b37b9ebbdf06@mail.gmail.com>
URL: https://gitlist.dev/e/b41dbf4a0709250754o189d99fcn4767b37b9ebbdf06%40mail.gmail.com
In-Reply-To: <b41dbf4a0709250748l52b64155k65b6adb16e8dbcd5@mail.gmail.com>

```
I'm trying to understand how rebase works, but I need some help to get it.
Suppose I do the following workflow... (see below)

In "version B" I introduce the "fix c", but in "version D" I realize
it should have
been in some other place. (commit D moves the fix to its proper place).
A-B-C-D-E

Now I want to 'rewrite history'.
I would like to move commit D after B
A-B-D'-C'-E

and then fold the commits B and D' into a single commit.
A-B'-C'-E

I somehow managed to get this done using "rebase -i"
by exchanging the 2 appropriate lines, and then deleting the second one,
but I'd like to understand how to do this from the command line...

Could anyone enlighten me? I've read git-rebase(1) several times,
but don't seem to get it right...


cat > file <<EOF
a
b
d
e
g
h
EOF
git add file
git commit -m 'A' -a
cat > file <<EOF
a
b
d
e
g
c
h
EOF
git commit -m 'B' -a
cat > file <<EOF
a
b
d
e
f
g
c
h
EOF
git commit -m 'C' -a
cat > file <<EOF
a
b
c
d
e
f
g
h
EOF
git commit -m 'D' -a
cat > file <<EOF
a
b
c
d
e
f
g
h
i
EOF
git commit -m 'E' -a

```
