Skip to contentSkip to conversation

how to combine 2 commits?

DISCUSSION bill lam 7 participants 9 messages Jun 15, 2016

lore
Share & tools
lore

bill lam

author
#0 lore raw

Sorry I don't know the correct git terminology for it. I make some changes to scripts but also accidentally changed all scripts to use dos linefeed. Failed to notice this and commit all changes. Then I tried to correct it by changing all scripts back to unix linefeed and commit again.

How to combine these 2 commits so that the changes of linefeed cancel out each other and the history only shows the intended changes of the few scripts.

Signature · 6 lines
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩234 李白  怨情
    美人捲珠簾  深坐蹙蛾眉  但見淚痕濕  不知心恨誰
#1 lore raw

On Monday 12 January 2009, bill lam <[email protected]> wrote about 'how to combine 2 commits?':

Quoted 3 lines

How to combine these 2 commits so that the changes of linefeed cancel out each other and the history only shows the intended changes of the few scripts.

Two ways I can think of:
git rebase --interactive (read "git help rebase" first) git merge --squash (read "git help merge" first)

The rebase is probably semantically closer to how you are thinking about things right now.

Signature · 4 lines
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
[email protected]                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     
author
#2 lore raw
Quoted 1 line · Boyd Stephen Smith Jr.

git rebase --interactive (read "git help rebase" first)

I tried rebase the last 3 commit, but it failed.

bill@b2j:jproject$ git log --pretty=oneline | head
39ed365c11391bede0e1b6578adfac6619b78c0a for yajpp to use unix LF
70c812db2439bc84a8dd7ea831067b9ebf29885c revert last crlf error
f338a768d635b868e6fddaae670ad91d46ea7c4e format scripts   
bill@b2j:jproject$ git rebase -i HEAD~3
error: Entry 'trunk/jcalc/mmenu-mm.ijs' not uptodate. Cannot merge.
fatal: merging of trees a1eafe6cdbb428f851d6ca878bbc53149fb7e7eb and
a00e6dcd3ec3f4ffde0d1aad1958db724093de69 failed

Could not apply 70c812d... revert last crlf error

It looks like cannot resolve conflict of linefeed changes. It was expected all scripts will conflict, so I have to abort the rebase.

What is the procedure to generate a patch of the HEAD from HEAD~4, then cancel all changes from HEAD~3 up to HEAD, and then apply the patch to the previous HEAD~4 ?

BTW, what is the norm of reply in this list, should it be reply to list only, or reply to group (list plus all cc)?

Signature · 7 lines
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
唐詩213 李商隱  無題二首之二
    颯颯東風細雨來  芙蓉塘外有輕雷  金蟾齧璅燒香入  玉虎牽絲汲井迴
    賈氏窺簾韓掾少  宓妃留枕魏王才  春心莫共花爭發  一寸想思一寸灰
#3 lore raw
Quoted 2 lines · bill lam

BTW, what is the norm of reply in this list, should it be reply to list only, or reply to group (list plus all cc)?

This list prefers list plus all cc.

Signature · 4 lines
Sincerely,
           Stephen R. van den Berg.

"I have a *cunning* plan!"
#4 lore raw
In reply to Boyd Stephen Smith Jr.
Quoted 6 lines · Boyd Stephen Smith Jr.

On Monday 12 January 2009, bill lam <[email protected]> wrote about 'how to combine 2 commits?':

Quoted 3 lines

How to combine these 2 commits so that the changes of linefeed cancel out each other and the history only shows the intended changes of the few scripts.

Quoted 6 lines

Two ways I can think of:
git rebase --interactive (read "git help rebase" first) git merge --squash (read "git help merge" first)

The rebase is probably semantically closer to how you are thinking about things right now.

Another way I can think of is - git format-patch + git apply, i.e. first generate 2 patches for the 2 commits and then apply them one on top of another.

Best regards,

Imran

Quoted 6 lines

--
Boyd Stephen Smith Jr. ,= ,-_-. =.
[email protected] ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy -'(. .)-'
http://iguanasuicide.net/ \_/

Signature · 7 lines
Imran M Yousuf
Entrepreneur & Software Engineer
Smart IT Engineering
Dhaka, Bangladesh
Email: [email protected]
Blog: http://imyousuf-tech.blogs.smartitengineering.com/
Mobile: +880-1711402557
#5 lore raw
In reply to bill lam

git terminology is "squash"

Quoted 21 lines · bill lam

Sorry I don't know the correct git terminology for it. I make some changes to scripts but also accidentally changed all scripts to use dos linefeed. Failed to notice this and commit all changes. Then I tried to correct it by changing all scripts back to unix linefeed and commit again.

How to combine these 2 commits so that the changes of linefeed cancel out each other and the history only shows the intended changes of the few scripts.

--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 唐詩234 李白 怨情
美人捲珠簾 深坐蹙蛾眉 但見淚痕濕 不知心恨誰
--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to bill lam
Quoted 9 lines · bill lam

Sorry I don't know the correct git terminology for it. I make some changes to scripts but also accidentally changed all scripts to use dos linefeed. Failed to notice this and commit all changes. Then I tried to correct it by changing all scripts back to unix linefeed and commit again.

How to combine these 2 commits so that the changes of linefeed cancel out each other and the history only shows the intended changes of the few scripts.

I tend to make lots of small commits on the work tree, and having to combine them meaningfully later.

I like using "git rebase -i HEAD~5" (if I want to rebase the last 5 commits). In the editor that pops up, I reorder the ones that I know should be together, and on each set to be squashed, I change the "pick" to "s" (for squash) on all but the first one. Save the file and it's all done.

Works like a charm. For me, moving commits around in an editor, deleting them even, is very intuitive.

#7 lore raw
Quoted 5 lines · Sitaram Chamarty

I like using "git rebase -i HEAD~5" (if I want to rebase the last 5 commits). In the editor that pops up, I reorder the ones that I know should be together, and on each set to be squashed, I change the "pick" to "s" (for squash) on all but the first one. Save the file and it's all done.

And right after, you probably want to do stg like

git diff master@{1} master

to see whether you actually changed the result by reordering your patches.

Signature · 1 line
Matthieu
#8 lore raw
Quoted 8 lines · Matthieu Moy
Quoted 5 lines · Sitaram Chamarty

I like using "git rebase -i HEAD~5" (if I want to rebase the last 5 commits). In the editor that pops up, I reorder the ones that I know should be together, and on each set to be squashed, I change the "pick" to "s" (for squash) on all but the first one. Save the file and it's all done.

Quoted 6 lines

And right after, you probably want to do stg like

git diff master@{1} master

to see whether you actually changed the result by reordering your patches.

I used to do that, but now I've stopped. If it doesn't conflict, I know it's good. I go straight to the equivalent of make && make test.

I must mention though, that I don't reorder the relative sequences of commits affecting the same file/set of files. That might have something to do with my confidence :-)