git interactive rebase: stop without commit
(TLDR)
Is there a way in git rebase -i
to stop for editing, without a commit id?
(/TLDR)
Longer version:
Background
With git rebase -i
, I get a text editor where I can define a list of commands, starting with pick COMMIT_ID
on each line.
One of the options is to replace "pick COMMIT_ID" with "edit COMMIT_ID", which means it will stop after the commit for me to do amend the commit, or to do some manual operations. Then I can proceed with git rebase --continue
.
From the list of options:
# e, edit = use commit, but stop for amending
Question
I wonder if there is an option to stop for editing, without picking any commit.
Motivation / Use case
E.g. if I want to squash a range of commits, and stop afterwards for some manual operations, I would have to put edit + squash in front of the same commit id - which is not allowed.
Instead, I would do something like this:
pick COMMIT_0 Change some colors
pick COMMIT_1 Make it faster
squash COMMIT_2 Fix a typo in previous commit
squash COMMIT_3 Fix another typo in previous commit
edit
pick COMMIT_4 Refactor some things
pick COMMIT_5 Introduce new options
Such an option would also allow to stop before the first commit in the sequence.
(I was going to say it would allow to edit before the initial commit of the entire history, but this is not true - the initial commit is never part of the rebase sequence)
If I do it like this, git says this:
Warning: the SHA-1 is missing or isn't a commit in the following line:
Interestingly, the effect is more or less what I want, it stops and I can do things. But I am sure this is not the intended way to do it.
git rebase git-interactive-rebase
add a comment |
(TLDR)
Is there a way in git rebase -i
to stop for editing, without a commit id?
(/TLDR)
Longer version:
Background
With git rebase -i
, I get a text editor where I can define a list of commands, starting with pick COMMIT_ID
on each line.
One of the options is to replace "pick COMMIT_ID" with "edit COMMIT_ID", which means it will stop after the commit for me to do amend the commit, or to do some manual operations. Then I can proceed with git rebase --continue
.
From the list of options:
# e, edit = use commit, but stop for amending
Question
I wonder if there is an option to stop for editing, without picking any commit.
Motivation / Use case
E.g. if I want to squash a range of commits, and stop afterwards for some manual operations, I would have to put edit + squash in front of the same commit id - which is not allowed.
Instead, I would do something like this:
pick COMMIT_0 Change some colors
pick COMMIT_1 Make it faster
squash COMMIT_2 Fix a typo in previous commit
squash COMMIT_3 Fix another typo in previous commit
edit
pick COMMIT_4 Refactor some things
pick COMMIT_5 Introduce new options
Such an option would also allow to stop before the first commit in the sequence.
(I was going to say it would allow to edit before the initial commit of the entire history, but this is not true - the initial commit is never part of the rebase sequence)
If I do it like this, git says this:
Warning: the SHA-1 is missing or isn't a commit in the following line:
Interestingly, the effect is more or less what I want, it stops and I can do things. But I am sure this is not the intended way to do it.
git rebase git-interactive-rebase
add a comment |
(TLDR)
Is there a way in git rebase -i
to stop for editing, without a commit id?
(/TLDR)
Longer version:
Background
With git rebase -i
, I get a text editor where I can define a list of commands, starting with pick COMMIT_ID
on each line.
One of the options is to replace "pick COMMIT_ID" with "edit COMMIT_ID", which means it will stop after the commit for me to do amend the commit, or to do some manual operations. Then I can proceed with git rebase --continue
.
From the list of options:
# e, edit = use commit, but stop for amending
Question
I wonder if there is an option to stop for editing, without picking any commit.
Motivation / Use case
E.g. if I want to squash a range of commits, and stop afterwards for some manual operations, I would have to put edit + squash in front of the same commit id - which is not allowed.
Instead, I would do something like this:
pick COMMIT_0 Change some colors
pick COMMIT_1 Make it faster
squash COMMIT_2 Fix a typo in previous commit
squash COMMIT_3 Fix another typo in previous commit
edit
pick COMMIT_4 Refactor some things
pick COMMIT_5 Introduce new options
Such an option would also allow to stop before the first commit in the sequence.
(I was going to say it would allow to edit before the initial commit of the entire history, but this is not true - the initial commit is never part of the rebase sequence)
If I do it like this, git says this:
Warning: the SHA-1 is missing or isn't a commit in the following line:
Interestingly, the effect is more or less what I want, it stops and I can do things. But I am sure this is not the intended way to do it.
git rebase git-interactive-rebase
(TLDR)
Is there a way in git rebase -i
to stop for editing, without a commit id?
(/TLDR)
Longer version:
Background
With git rebase -i
, I get a text editor where I can define a list of commands, starting with pick COMMIT_ID
on each line.
One of the options is to replace "pick COMMIT_ID" with "edit COMMIT_ID", which means it will stop after the commit for me to do amend the commit, or to do some manual operations. Then I can proceed with git rebase --continue
.
From the list of options:
# e, edit = use commit, but stop for amending
Question
I wonder if there is an option to stop for editing, without picking any commit.
Motivation / Use case
E.g. if I want to squash a range of commits, and stop afterwards for some manual operations, I would have to put edit + squash in front of the same commit id - which is not allowed.
Instead, I would do something like this:
pick COMMIT_0 Change some colors
pick COMMIT_1 Make it faster
squash COMMIT_2 Fix a typo in previous commit
squash COMMIT_3 Fix another typo in previous commit
edit
pick COMMIT_4 Refactor some things
pick COMMIT_5 Introduce new options
Such an option would also allow to stop before the first commit in the sequence.
(I was going to say it would allow to edit before the initial commit of the entire history, but this is not true - the initial commit is never part of the rebase sequence)
If I do it like this, git says this:
Warning: the SHA-1 is missing or isn't a commit in the following line:
Interestingly, the effect is more or less what I want, it stops and I can do things. But I am sure this is not the intended way to do it.
git rebase git-interactive-rebase
git rebase git-interactive-rebase
asked Nov 14 '18 at 11:48
donquixotedonquixote
1,87811934
1,87811934
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You have one, two, or three options, depending on some circumstances.
First option
Insert
exec false
or its short form
x false
at the point where you want to stop. As you may know, exec
runs the shell command at the point where the command occurs; but if the command exits with failure, git rebase
stops, and the command false
always exits with failure.
Second option
If you are using Git 2.20 or later, you can insert
break
or its short form
b
at the point where you want to stop. This command was introduced for the very purpose that you are asking for.
Third option
Mark the commit before the point where you want to stop with edit
instead of pick
. Obviously, this does not work if you want to stop before the first commit or after a squash
or fixup
commit.
2
Also, change the last squash to an edit, and do the squash yourself withgit reset --soft @^; git commit --amend
– jthill
Nov 14 '18 at 13:10
add a comment |
I don't know if that is possible. After squash you must do second interactive rebase and then modified commit.
Ok, going to wait if someone proposes a better workaround.
– donquixote
Nov 14 '18 at 12:25
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299542%2fgit-interactive-rebase-stop-without-commit%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have one, two, or three options, depending on some circumstances.
First option
Insert
exec false
or its short form
x false
at the point where you want to stop. As you may know, exec
runs the shell command at the point where the command occurs; but if the command exits with failure, git rebase
stops, and the command false
always exits with failure.
Second option
If you are using Git 2.20 or later, you can insert
break
or its short form
b
at the point where you want to stop. This command was introduced for the very purpose that you are asking for.
Third option
Mark the commit before the point where you want to stop with edit
instead of pick
. Obviously, this does not work if you want to stop before the first commit or after a squash
or fixup
commit.
2
Also, change the last squash to an edit, and do the squash yourself withgit reset --soft @^; git commit --amend
– jthill
Nov 14 '18 at 13:10
add a comment |
You have one, two, or three options, depending on some circumstances.
First option
Insert
exec false
or its short form
x false
at the point where you want to stop. As you may know, exec
runs the shell command at the point where the command occurs; but if the command exits with failure, git rebase
stops, and the command false
always exits with failure.
Second option
If you are using Git 2.20 or later, you can insert
break
or its short form
b
at the point where you want to stop. This command was introduced for the very purpose that you are asking for.
Third option
Mark the commit before the point where you want to stop with edit
instead of pick
. Obviously, this does not work if you want to stop before the first commit or after a squash
or fixup
commit.
2
Also, change the last squash to an edit, and do the squash yourself withgit reset --soft @^; git commit --amend
– jthill
Nov 14 '18 at 13:10
add a comment |
You have one, two, or three options, depending on some circumstances.
First option
Insert
exec false
or its short form
x false
at the point where you want to stop. As you may know, exec
runs the shell command at the point where the command occurs; but if the command exits with failure, git rebase
stops, and the command false
always exits with failure.
Second option
If you are using Git 2.20 or later, you can insert
break
or its short form
b
at the point where you want to stop. This command was introduced for the very purpose that you are asking for.
Third option
Mark the commit before the point where you want to stop with edit
instead of pick
. Obviously, this does not work if you want to stop before the first commit or after a squash
or fixup
commit.
You have one, two, or three options, depending on some circumstances.
First option
Insert
exec false
or its short form
x false
at the point where you want to stop. As you may know, exec
runs the shell command at the point where the command occurs; but if the command exits with failure, git rebase
stops, and the command false
always exits with failure.
Second option
If you are using Git 2.20 or later, you can insert
break
or its short form
b
at the point where you want to stop. This command was introduced for the very purpose that you are asking for.
Third option
Mark the commit before the point where you want to stop with edit
instead of pick
. Obviously, this does not work if you want to stop before the first commit or after a squash
or fixup
commit.
edited Dec 14 '18 at 9:58
answered Nov 14 '18 at 13:05
j6tj6t
1,266139
1,266139
2
Also, change the last squash to an edit, and do the squash yourself withgit reset --soft @^; git commit --amend
– jthill
Nov 14 '18 at 13:10
add a comment |
2
Also, change the last squash to an edit, and do the squash yourself withgit reset --soft @^; git commit --amend
– jthill
Nov 14 '18 at 13:10
2
2
Also, change the last squash to an edit, and do the squash yourself with
git reset --soft @^; git commit --amend
– jthill
Nov 14 '18 at 13:10
Also, change the last squash to an edit, and do the squash yourself with
git reset --soft @^; git commit --amend
– jthill
Nov 14 '18 at 13:10
add a comment |
I don't know if that is possible. After squash you must do second interactive rebase and then modified commit.
Ok, going to wait if someone proposes a better workaround.
– donquixote
Nov 14 '18 at 12:25
add a comment |
I don't know if that is possible. After squash you must do second interactive rebase and then modified commit.
Ok, going to wait if someone proposes a better workaround.
– donquixote
Nov 14 '18 at 12:25
add a comment |
I don't know if that is possible. After squash you must do second interactive rebase and then modified commit.
I don't know if that is possible. After squash you must do second interactive rebase and then modified commit.
answered Nov 14 '18 at 12:16
TomaszTomasz
215
215
Ok, going to wait if someone proposes a better workaround.
– donquixote
Nov 14 '18 at 12:25
add a comment |
Ok, going to wait if someone proposes a better workaround.
– donquixote
Nov 14 '18 at 12:25
Ok, going to wait if someone proposes a better workaround.
– donquixote
Nov 14 '18 at 12:25
Ok, going to wait if someone proposes a better workaround.
– donquixote
Nov 14 '18 at 12:25
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53299542%2fgit-interactive-rebase-stop-without-commit%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown