Questions tagged [git-rebase]

With the git-rebase command, you can take the changes from one branch and replay them on top of another branch.

git rebase allows you to specify the starting point of a branch, that is, to "move" changes from a branch on top of another branch. You can also specify specific commits even if they don't have branches associated with them

The Git book has a chapter on rebasing has some nice examples with diagrams that help to understand the general concept, although each system has different capabilities.

Another common way to integrate changes is to merge to branches. The difference between these two operation has been covered in Stack Overflow:

Also on the usage of git svn the equivalent to git pull is a git svn rebase that rebases local changes ahead of the commits existing in the subversion repository.

A rebase can be undone as explained in "Undoing a rebase"

1451 questions
172
votes
9 answers

rebase in progress. Cannot commit. How to proceed or stop (abort)?

When I run: git status I see this: rebase in progress; onto 9c168a5 You are currently rebasing branch 'master' on '9c168a5'. (all conflicts fixed: run "git rebase --continue") nothing to commit, working directory clean When I do: ls `git…
Joseph Chambers
  • 2,688
  • 3
  • 17
  • 32
169
votes
7 answers

Why does git-rebase give me merge conflicts when all I'm doing is squashing commits?

We have a Git repository with over 400 commits, the first couple dozen of which were a lot of trial-and-error. We want to clean up these commits by squashing many down into a single commit. Naturally, git-rebase seems the way to go. My problem is…
Ben Hocking
  • 7,008
  • 4
  • 31
  • 51
168
votes
6 answers

Change old commit message on Git

I was trying to edit an old commit message as explained here. The thing is that now, when I try to run rebase -i HEAD~5 it says interactive rebase already started. So then I try: git rebase --continue but got this error: error: Ref…
Pablo Fernandez
  • 94,980
  • 54
  • 180
  • 225
165
votes
3 answers

How do I select a merge strategy for a git rebase?

git-rebase man page mentions -X
Kornel
  • 91,239
  • 30
  • 200
  • 278
160
votes
2 answers

How do you rebase the current branch's changes on top of changes being merged in?

Okay. If I'm on a branch (say working), and I want to merge in the changes from another branch (say master), then I run the command git-merge master while on the working branch, and the changes get merged in without rebasing the history at all. If I…
Jonathan M Davis
  • 34,779
  • 15
  • 69
  • 99
154
votes
4 answers

How to abort a git rebase from inside vim during interactive editing

When I do an interactive rebase, e.g. git rebase -i HEAD~3 the rebase interactive editor (vim in my case) opens to let me edit the commits to rebase pick c843ea2 Set Vim column limit to 80 (OS X) pick fc32eac Add Bash alias for `pbcopy` (OS…
René Link
  • 38,761
  • 11
  • 84
  • 115
146
votes
5 answers

Git rebase merge conflict cannot continue

I'm trying to rebase 'dev' to catch up to 'master' branch. $ git checkout dev $ git rebase master First, rewinding head to replay your work on top of it... Applying: Corrected compilation problems that came from conversion from SVN. Using index…
awm
  • 2,246
  • 2
  • 15
  • 25
136
votes
6 answers

can't push to branch after rebase

We use git and have a master branch and developer branches. I need to add a new feature and then rebase the commits to master, then push master to CI server. The problem is that if I have conflicts during rebase I cannot push to my remote developer…
Matt
  • 2,161
  • 4
  • 19
  • 20
134
votes
1 answer

Difference between git pull --rebase and git pull --ff-only

Let's say origin/master has commit A--B--C and my local/master has commit A--B--D. What will happen if I use git pull --rebase ? What will happen if I use git pull --ff-only ? Is there any difference in the resulting commit tree ?
Nico
  • 5,107
  • 4
  • 20
  • 30
121
votes
3 answers

How do I reword the very first git commit message?

I have a working tree containing 3 commmits: ➜ ~myproject git:(master) git log commit a99cce8240495de29254b5df8745e41815db5a75 Author: My Name Date: Thu Aug 16 00:59:05 2012 +0200 .gitignore edits commit…
Henrik
  • 2,061
  • 4
  • 19
  • 29
118
votes
4 answers

Git: How to reuse/retain commit messages after 'git reset'?

As Git user I regular come across the situation, that I need to rework one or more commits in a way which do not fit into --amend or rebase -iwith fixup commits. Typically I would do something like git reset HEAD~1 # hack, fix, hack git commit -a #…
bentolor
  • 2,636
  • 2
  • 18
  • 30
115
votes
5 answers

git remove merge commit from history

My Git history looks like that : I would like to squash the purple commits into a single one. I don't want to see them ever again in my commit log. I've tried to do a git rebase -i 1, but even though 1 is on the blue branch (cf. picture), I still…
Benjamin Toueg
  • 9,289
  • 7
  • 39
  • 69
110
votes
2 answers

Git rebase fails, 'Your local changes to the following files would be overwritten by merge'. No local changes?

Here is my transcript from trying to merge my bugfix branch onto my master branch in preparation to push it upstream. There have been some upstream changes pulled into master since the bugfix branch was created, and it now refuses to rebase. The…
jhogendorn
  • 5,523
  • 3
  • 23
  • 35
108
votes
4 answers

Change timestamps while rebasing git branch

I have reorganized the commits in a branch before it is going to be made public causing the timestamps of the commits to be in an mixed up order. I would rather have them be all be today with only seconds in between. Obviously these time stamps…
tarsius
  • 7,061
  • 5
  • 30
  • 42
102
votes
4 answers

git rebase merge conflict

I forked a github repo and worked on my github repo. I have made pull-requests and it was completed. After that the upstream had some more commits so now I want to rebase, I guess thats what I have to do. But I'm getting these merge…
pahnin
  • 4,631
  • 11
  • 34
  • 56
1 2
3
96 97