You are not logged in.

#1 2021-11-21 21:42:52

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,732
Website

Non-interactive git fixup of the last commit only [solved]

My goal is to have a non-interactive git call that will:

1) rebase/fixup the last commit
2) retain the commit message of the 2nd to last commit.

To date, I have been doing this in a few steps.
1) Make my small change to the code and run git commit -am "small change"
2) git rebase -i HEAD~2 ... once in the editor change the 'pick' on the 2nd line to 'f'

I found a number of alternatives searching but non of them accomplish what I am after.  Thanks.

Last edited by graysky (2021-11-22 07:24:33)

Offline

#2 2021-11-21 21:56:32

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 714

Re: Non-interactive git fixup of the last commit only [solved]

Why not `git commit --amend`?

Offline

#3 2021-11-21 22:07:58

progandy
Member
Registered: 2012-05-17
Posts: 5,320

Re: Non-interactive git fixup of the last commit only [solved]

bulletmark wrote:

Why not `git commit --amend`?

Specifically

git commit --amend --no-edit

https://riptutorial.com/git/example/122 … g-a-commit
https://git-scm.com/docs/git-commit#Doc … ---no-edit

As for rebase, use --autosquash for the rebse and --fixup=COMMITID or so for the second commit.
https://riptutorial.com/git/topic/598/squashing
https://git-scm.com/docs/git-commit#Doc … ltcommitgt
https://git-scm.com/docs/git-rebase

Last edited by progandy (2021-11-21 22:15:43)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#4 2021-11-22 07:24:19

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,732
Website

Re: Non-interactive git fixup of the last commit only [solved]

progandy wrote:
bulletmark wrote:

Why not `git commit --amend`?

Specifically

git commit --amend --no-edit

Thanks guys... that did it.

Offline

Board footer

Powered by FluxBB