How to use git rebase to clear a messy story

After weeks of working with half a dozen different branches and mergers, both on my laptop and at work, as well as on the desktop at home, my story is a bit confused. For example, I just made a selection and then combined the master with origin / master. Now when I do git show-branch, the output is as follows:

 !  [login] Changed domain name.
  !  [master] Merge remote branch 'origin / master'
   !  [migrate-1.9] Migrating to 1.9.1 on Heroku
    !  [rebase-master] Merge remote branch 'origin / master'
 ----
  - - [master] Merge remote branch 'origin / master'
  + + [master ^ 2] A bit of re-arranging and cleanup.
  - - [master ^ 2 ^] Merge branch 'rpx-login'
  ++ [master ^ 2 ^^ 2] Commented out some debug logging.
  ++ [master ^ 2 ^^ 2 ^] Monkey-patched Rack :: Request # ip
  ++ [master ^ 2 ^^ 2 ~ 2] dump each request to log
 ....

I would like to clear this with git rebase. For this purpose, I created a new branch, rebase-master, and on this branch I tried git rebase <common-ancestor>. However, I have to resolve many conflicts, and the end result on the rebase-master server no longer matches the corresponding version on master, which has already been tested and works!

It seemed to me that I saw a solution to this, but I can no longer find it. Does anyone know how to do this? Or will these confusing link names disappear when I start deleting unnecessary branches that Iโ€™ve already merged with?

I am the only developer in this project, so no one will be affected.

+8
git merge rebase
Jun 11. '10 at 21:00
source share
2 answers

The best way to clear a minimized story is to keep the story linear. You do this by avoiding any merging except fast forward.

The workflow is as follows.

$ git checkout -b foobranch <do stuff> $ git commit <do stuff> $ git commit ... 

When you need to integrate a branch into a master, do not merge it. Instead, reinstall this branch against the master. This will make the branch no longer look like a branch, but simply more growth at the top of the tree. You resolve merge conflicts during rebase.

 $ git fetch origin $ git rebase origin/master 

Now merge the branch into a master. It will be an accelerated merger.

 $ git checkout master $ git merge foobranch 

And now push the work upstream.

 $ git push 
+10
Jul 10 2018-10-10T00:
source share

The usual process for repositions, in which you can force a branch to push (replacing the deleted history with a new one created locally using rebase), is as follows:

 git rebase --interactive 

But again, this is only permissible if you only pull one from your repositories, and even then you will have to reinitialize some of your local branches with new rewritable track branches that have been rewritten.

In a dashboard session, you can trim the Git record and squash history to get the story you need.

+5
Jun 11 '10 at 21:35
source share



All Articles