简体   繁体   中英

Is git rebasing the wrong branch?

I have three branches:

master
dev
feature

My branch master is up to date. I want to rebase my branch feature with master

git checkout feature
git rebase master

But at the beginning I see:

First, rewinding head to replay your work on top of it...
Applying: ajout model widget desc + stats
Using index info to reconstruct a base tree...

ajout model widget desc + stats is the first commit on this branch. So the rebase is using the wrong version of my branch.

The result is a lot of conflits, and my file that I have committed is gone.

Exemple :

<<<<<<< HEAD
            $this->createWidget('samples/footer','content', array('channeltitle'=>$channelTitle));
=======
            $this->createWidget('samples/desc','desc', array('channelTitle' => $channelTitle));
            $this->createWidget('samples/statistics','statistics', array('channelTitle' => $channelTitle));
            $this->createWidget('samples/footer','footer');
>>>>>>> ajout model widget desc + stats

he want to rebase the head of the branch master with the wrong commit...(ajout model widget desc + stats)

I searched for a solution to rebase my branch with the lastest commit.

| * fac92fe (HEAD, origin/feature, feature) work better
| * a366488 works in AJAX !
| * f5d120e appel ajax dans la vue
| * c1f8360 ajout model ajax bestVide, FeaturedChannel (no cache active)
| * 211fda0 ajout widget network
| * 4d1c2a5 social link
| * c511472 ajout model widget desc + stats
|/
| *   2f8ddcc (origin/master, origin/HEAD, master) Merge branch 'dev'
| |\
|/ /
| * 0c859da dev Channel/Network + fix Artifice
|/
| * 41c0cfb (origin/update_channel, update_channel) update
| * 66015b6 ajout bannerimg
| * 1433e90 ajout entete script
| * 619d850 ajout dossiet script crontab
| * 8c4b2c8 channel inactive + simplification
| * 37c453c modif network
| * b764ddb fisrt version script update_channel
|/
*   5676028 Merge branch 'generalmodels'
|\
| * da10f84 Return JSON in utf8
| * 10f7897 good job bro
| * 3eadddc config grunt
:

It doesn't actually look wrong.

Your output is expected

  1. First rewind all your commits from feature
  2. Then apply all the commits from master. This cannot fail and gives no particular output.
  3. Then apply all your commits, in order, starting with ajout...

In your case it gives conflicts. It's not unusual so you need to resolve them in the editor of your choice, then continue the rebase . In your current state the rest of the commits are still waiting to be applied, they are not missing.

  1. Fix conflicts. For all files run git add <file name>
  2. Then git rebase --continue
  3. Do this until the rebase is complete.

If it feels like havoc you can always abort the rebase with git rebase --abort

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM