User Tools

Site Tools


git_rebase

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git_rebase [2019/03/07 14:40]
rpjday [The fundamental rebase operation]
git_rebase [2019/04/06 21:34] (current)
rpjday [Removing a sequence of commits]
Line 6: Line 6:
  
 <​code>​ <​code>​
-git rebase [-i | --interactive] [<​options>​] [--exec <​cmd>​] [--onto <​newbase>​] +git rebase [-i | --interactive] [<​options>​] 
-        [<​upstream>​ [<​branch>​]] +  ​[--exec <​cmd>​] [--onto <​newbase>​] 
-git rebase [-i | --interactive] [<​options>​] [--exec <​cmd>​] [--onto <​newbase>​] +  [<​upstream>​ [<​branch>​]] 
-        --root [<​branch>​] +   
-git rebase --continue | --skip | --abort | --quit | --edit-todo | --show-current-patch+git rebase [-i | --interactive] [<​options>​] 
 +  ​[--exec <​cmd>​] [--onto <​newbase>​] 
 +  --root [<​branch>​] 
 +  - 
 +git rebase --continue | --skip | --abort | --quit | 
 +   --edit-todo | --show-current-patch
 </​code>​ </​code>​
  
 ===== The fundamental rebase operation ===== ===== The fundamental rebase operation =====
  
-Three components:+Three components ​define a rebase:
  
   * the //branch// to be rebased   * the //branch// to be rebased
Line 21: Line 26:
   * the target //commit// onto which to rebase   * the target //commit// onto which to rebase
  
-Simple example:+===== Examples ===== 
 + 
 +==== Simple example ​====
  
 <​code>​ <​code>​
-              A---B---C topic+              A---B---C ​          ​topic
              /              /
-        D---E---F---G master+        D---E---F---G ​            ​master
 </​code>​ </​code>​
  
-Example requiring ​''​%%--%%onto newbase'':​+One of: 
 + 
 +<​code>​ 
 +$ git checkout topic 
 +$ git rebase master 
 +</​code>​ 
 + 
 +or: 
 + 
 +<​code>​ 
 +$ git rebase master topic 
 +</​code>​ 
 + 
 +<​code>​ 
 +                      A'--B'--C' ​ topic 
 +                     / 
 +        D---E---F---G ​            ​master 
 +</​code>​ 
 + 
 +==== Example requiring "--onto newbase" ====
  
 <​code>​ <​code>​
Line 38: Line 64:
                         o---o---o ​ topic                         o---o---o ​ topic
 </​code>​ </​code>​
-===== DESCRIPTION ===== 
  
 <​code>​ <​code>​
-If <​branch>​ is specified, ​git rebase ​will perform an automatic +git rebase ​--onto master next topic
-git checkout <​branch>​ before doing anything else. Otherwise it +
-remains on the current branch.+
 </​code>​ </​code>​
- 
-In other words, the final optional argument ''​[branch]''​ can always be omitted if you first just: 
  
 <​code>​ <​code>​
-$ git checkout <​branch>​+                          o---o---o ​ topic 
 +                         / 
 +        o---o---o---o---o ​ master 
 +             \ 
 +              o---o---o---o---o ​ next
 </​code>​ </​code>​
  
-then just pretend it says ''​HEAD''​. 
  
-===== Examples ===== 
  
 ==== Removing a sequence of commits ===== ==== Removing a sequence of commits =====
Line 67: Line 90:
  
 <​code>​ <​code>​
-$ git rebase --onto B D+$ git rebase --onto B D [HEAD]
 </​code>​ </​code>​
  
git_rebase.1551969643.txt.gz · Last modified: 2019/03/07 14:40 by rpjday