Following situation: two branches, upstream-dev and personal-dev, which vary a lot due to not yet merged or rejected features.
I then create a new feature branch on personal-dev. I do some commits, testing etc. At the end, I want to rebase the feature branch onto upstream-dev to properly create a pull request on github.
But git drags along a lot of changes and differences between personal-dev and upstream-dev, too? Why is that? I though a rebase takes the commits of a branch and reapplies them on another branch.
I can though perfectly cherry-pick the list of commits from my feature branch. That works without further manual interaction.
Graphics:
K -> L -> M <-- upstream-dev
K -> A -> L -> B -> M <-- personal-dev
Feature branch: [K -> A -> L -> B -> M ] -> C -> D -> E
Expected behavior when I'm rebasing: [K -> L -> M] -> C -> D -> E <-- feature branch
Actually happening: [K -> A -> L -> B -> M] -> C -> D -> E (I see on github that the PR tries to not only merge C, D and E to upstream, but personal commits like A and B aswell.
Can I do what I intend to do with rebase somehow? Or is rebase just to include newer commits from the branch, the feature branch was originally derivated of?
What did I get wrong with the rebase functionality?
Thanks for help!
Edit: Here a demonstration of what I'm trying to do. It's in German, but I from the commands you can see, what I do and that it's going wrong.
$ git checkout develop
Zu Branch 'develop' gewechselt
Ihr Branch ist auf demselben Stand wie 'mpw/develop'.
$ git status
Auf Branch develop
Ihr Branch ist auf demselben Stand wie 'mpw/develop'.
nichts zu committen, Arbeitsverzeichnis unverändert
$ git pull
Bereits aktuell.
$ git branch testrebase
$ git checkout testrebase
Zu Branch 'testrebase' gewechselt
$ vim application/Controller/RunController.php
$ git add application/Controller/RunController.php
$ git commit -m 'Testcommit'
[testrebase 184aae08] Testcommit
1 file changed, 1 insertion(+), 1 deletion(-)
$ git status
Auf Branch testrebase
nichts zu committen, Arbeitsverzeichnis unverändert
$ git checkout hotfix/v0.17.18
Zu Branch 'hotfix/v0.17.18' gewechselt
Ihr Branch ist auf demselben Stand wie 'origin/hotfix/v0.17.18'.
$ git rebase hotfix/v0.17.18 testrebase
Zunächst wird der Branch zurückgespult, um Ihre Änderungen
darauf neu anzuwenden ...
Erzeuge Patches: 100% (15/15), Fertig.
Wende an: remove psd files bloating application size
Wende an: merge commit
Verwende Informationen aus der Staging-Area, um ein Basisverzeichnis nachzustellen ...
M application/Controller/RunController.php
M application/Library/Functions.php
M application/Library/Session.php
M application/Model/Email.php
M application/Model/Page.php
M application/View/public/error.php
M application/View/public/run/index.php
M setup.php
.git/rebase-apply/patch:76: trailing whitespace.
warning: 1 Zeile fügt Whitespace-Fehler hinzu.
Falle zurück zum Patchen der Basis und zum 3-Wege-Merge ...
automatischer Merge von setup.php
KONFLIKT (Inhalt): Merge-Konflikt in setup.php
error: Merge der Änderungen fehlgeschlagen.
Anwendung des Patches fehlgeschlagen bei 0002 merge commit
Benutzen Sie 'git am --show-current-patch', um den
fehlgeschlagenen Patch zu sehen.
Lösen Sie alle Konflikte manuell auf, markieren Sie diese mit
"git add/rm <konfliktbehaftete_Dateien>" und führen Sie dann
"git rebase --continue" aus.
Sie können auch stattdessen diesen Commit auslassen, indem
Sie "git rebase --skip" ausführen.
Um abzubrechen und zurück zum Zustand vor "git rebase" zu gelangen,
führen Sie "git rebase --abort" aus.
$ git status
Rebase im Gange; auf adaffc5f
Sie sind gerade beim Rebase von Branch 'testrebase' auf 'adaffc5f'.
(beheben Sie die Konflikte und führen Sie dann "git rebase --continue" aus)
(benutzen Sie "git rebase --skip", um diesen Patch auszulassen)
(benutzen Sie "git rebase --abort", um den ursprünglichen Branch auszuchecken)
Nicht zusammengeführte Pfade:
(benutzen Sie "git reset HEAD <Datei>..." zum Entfernen aus der Staging-Area)
(benutzen Sie "git add/rm <Datei>...", um die Auflösung zu markieren)
von beiden geändert: setup.php
keine Änderungen zum Commit vorgemerkt (benutzen Sie "git add" und/oder "git commit -a")
$ git rebase --abort
As you can see, it complains about ”setup.php“ which was edited by both although I only changed ”application/Controller/RunController.php“, where I added a single comment line.