Questions tagged [git-interactive-rebase]

65 questions
61
votes
2 answers

Merge commits don't appear in git rebase --interactive

git log reveals the following: commit 1abcd[...] Author: [...] Date: [...] [Useful commit] commit 2abcd[...] Author: [...] Date: [...] Merge branch [...] of [etc. etc.] commit 3abcd[...] Author: [...] Date: [...] [Useful…
NWard
  • 2,016
  • 2
  • 20
  • 24
36
votes
1 answer

How do I rebase while skipping a particular commit?

Is there a way to rebase a branch onto another while skipping a particular (conflicting) commit on the other branch? For example, I want to rebase mybranch onto master, but master contains a commit that will conflict with the commits in master, so I…
Phillip
  • 5,366
  • 10
  • 43
  • 62
25
votes
1 answer

git rebase -i a branch onto itself

I had the following in my repo Master--- \ Next-->Commit A.1,Commit A.2,Commit A.3 --...... I want to fix-up the A.* commits into one commit describing the feature A. I tried git rebase -i origin next, but that didn't work how I…
ndp
  • 873
  • 1
  • 11
  • 24
24
votes
1 answer

How can I squash commits without tracking a remote branch?

I have a brand new git repo. It has three commits. I'd like to squash them together so my project history looks clean, and others don't see my hacky commits. Obviously nobody else has seen the repo, as it's brand new, so changing history is not a…
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
24
votes
2 answers

Git: interactive rebase lists incorrect (too many) commits

When I run git rebase -i HEAD~2, it lists 11 commits instead of 2. Why? What I've done prior to this was: Checked out upstream/branchA Rebased my new local copy of branchA with master Tried to push my local branchA back to upstream Git complained…
Jakob Jingleheimer
  • 30,952
  • 27
  • 76
  • 126
19
votes
3 answers

Git: Interactively rebase a range of commits

I'm trying to rebase -i a few commits that occurred a while back in my history. Say I have a log like this: * 5e32fb0 (HEAD -> master) Add latest feature * 106c31a Add new feature * 2bdac33 Add great feature ...100 other commits... * 64bd9e7 Add…
achalk
  • 3,229
  • 3
  • 17
  • 37
18
votes
6 answers

git interactive rebase squash into next commit

In Git I can use an interactive rebase to re-write history, this is great because in my feature branch I made a ton of commits with partially working code as I explored different refactors and ways of getting it done. I'd like to squash a lot of the…
Josh R
  • 1,970
  • 3
  • 27
  • 45
16
votes
2 answers

How do I squash and edit the same commit?

When I do an interactive rebase in git, how do I squash a commit and also stop end edit the same commit?
cambunctious
  • 8,391
  • 5
  • 34
  • 53
14
votes
2 answers

Git rebase from one branch to another

I have the following case : K---L new-feature / H---I---J dev-team1 / E---F---G dev-main / A---B---C---D master And I want to move only the…
radu c
  • 4,138
  • 7
  • 30
  • 45
10
votes
1 answer

Git open default git editor instead of VIM or any other editor (Git Rebase)

I recently installed Vim. Now, when I rebase my branch in interactive mode, Git automatically opens Vim. However, I do not want to open Vim in interactive mode; instead, I want to open default Git interactive mode editor. How can I set the default…
Jaykumar Patel
  • 26,836
  • 12
  • 74
  • 76
8
votes
3 answers

Abort Interactive Rebase when VSCode is set as the Git Editor

I've set VSCode to be my git editor as detailed here. When I try to do: git rebase HEAD~3 -i it opens a new Code window, and as soon as the interactive rebase VSCode window closes the window that contained the terminal that fired off the command…
CTS_AE
  • 12,987
  • 8
  • 62
  • 63
8
votes
2 answers

How to run git rebase interactive mode to remove duplicate commits

I made a mistake when I rebase to a recent commit. ( I forgot to git fetch --all first, then rebase), and I've committed and pushed to the remote branch since. Now I did the rebase properly by fetching first, solved the conflicts, and pushed to the…
David Zhao
  • 4,284
  • 11
  • 46
  • 60
5
votes
1 answer

Git: How to skip to the end of a rebase and keep all changes so far?

I'm in the middle of an interactive rebase and I've already amended several commits I have several remaining commits that I've marked to edit, but I've decided that I don't want to edit them anymore How can I end the rebase (early, if you would) but…
ApplePieGiraffe
  • 155
  • 1
  • 8
5
votes
2 answers

Why recently, git rebase -i squash results in detached head

Why does git rebase -i with squashes recently result in a detached head? It used to to update my current branch with the result of the interactive rebase. How do I get interactive rebase to stop going to detached HEAD? I've always used git rebase -i…
joseph
  • 2,429
  • 1
  • 22
  • 43
5
votes
0 answers

Keep intermediate branch pointers after rebasing interactively

While working on my feature branches, I constantly re-order and squash them with git rebase -i to keep a cleaner version of my history. Sometimes I work on several features that depend on each other (the rules in my team are to make PRs as small as…
sdeleon28
  • 329
  • 1
  • 11
1
2 3 4 5