8

How to do a git rebase - Morris Jobke

 3 years ago
source link: https://morrisjobke.de/2015/12/03/How-to-do-a-git-rebase/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to do a git rebase 03 Dec 2015

How I do the git rebase:

  • checkout master and fetch the latest stuff:

      $ git checkout master
      $ git pull
    
  • switch to the branch that should be rebased and start an interactive rebase:

      $ git rebase --interactive master
    
  • an editor will open that lists of all your commits that should be rebased - close it which means that all commits should stay as they are (e.g. no squashing of multiple commits into one)
  • (a) this will apply each commit and will stop once it can’t be applied properly (conflict) or once all commits are applied (goto (b))
  • check carefully the git status output and resolve the conflicts (both modified entries)
merge conflict
  • once this is done - add the changed files as usual with

      $ git add FILENAME
    
  • once all files with conflict are fixed the rebase can be continued:

      $ git rebase --continue
    
  • this will use the old commit message and bundle the merge conflict changes into it
  • now it will continue at (a)
  • (b) once the rebase is done checking the current branch is always good

I use my own alias git lg that shows clearly how many commits are between the current branch and the master (should only be yours). A git lg with 8 commits above master on branch def looks like this:

merge conflict

Note: The tricky part is to keep calm during the initial rebase session ;)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK