Reputation: 43477
I have the following situation:
master
;x
off of master
;master
, and I would like to have this available in x
as well. It is my understanding that I have to rebase x
on master
.This is what I do:
x
branch: VCS -> Git -> Branches -> Local branches -> x -> Checkout
;VCS -> Git -> Rebase -> Select master in onto
.At this point an error shows up telling me to check the VC console for details. This is what the console shows:
23:59:22.839: git rebase -i -v -m refs/heads/master
Cannot rebase: You have unstaged changes.
Additionally, your index contains uncommitted changes.
Please commit or stash them.
There are no pending changes in any branch anywhere. Everything is committed (and pushed to Bitbucket if that makes any difference). Am I doing this right? How can I rebase my branch on master
?
Upvotes: 2
Views: 8439
Reputation: 9749
The error happens because you have unstaged changes, stash them or commit them will allow you to do the rebase command.
BUT, I think what you are doing here is totally wrong.
first, you are not supposed to commit on a master branch, you should commit on the topic branch and merge/rebase it with/on the master branch.
second, according to what you want to do, it's rebasing master on x, not rebasing x on master.
so you should
1, checkout master --> git checkout master
2, rebase on x --> git rebase x
3, do some merge job
4, continue the rebase --> git rebase --continue
btw, you should read pro-git, it's free and it's a very good book.
EDIT:
After reading the url you post, I think I had some misunderstanding here.
say you have this:
$ git log --oneline --graph --decorate --all
* c85d8bd (HEAD, master) dev on master again
| * 431a9c6 (topic) dev on topic
|/
* 4ad2cc4 dev on master
* d576e88 init
and here we are going to try two rebase commands:
1, rebase master on topic
git checkout master
git rebase topic
this will make the history look like this:
$ git log --oneline --graph --decorate --all
* 03021da (HEAD, master) dev on master again
* 431a9c6 (topic) dev on topic
* 4ad2cc4 dev on master
* d576e88 init
2, rebase topic on master
git checkout topic
git rebase master
your history will be like:
$ git log --oneline --graph --decorate --all
* adc93f1 (HEAD, topic) dev on topic
* c85d8bd (master) dev on master again
* 4ad2cc4 dev on master
* d576e88 init
it's all about you want whom to be on whom:)
and I'm remembering this in this way:
merge with <branch>
rebase on <branch>
but there is an exception, while using:
git rebase --onto
you can find these details in pro-git's Chapter 3.6
Upvotes: 2