Essential Git for Scientists
  • Introduction
  • Basic Concepts
    • Version Control
    • Git
    • Repo
    • Commits
    • Branches
    • Remotes
    • GitHub
    • De-centralisation
    • Summary
  • Basic Operations
    • Install Git
    • Create a Repo
    • Make a Commit
    • Inspect a Previous Commit
    • Revert a Change
    • Make a Branch
    • Extend a Branch
    • Fast-forward merge
    • Resolve conflicts
  • Intermediate Concepts
    • Commits
    • Three Trees
    • Rebase
    • Fetch
    • Pull
    • Push
  • Advanced Concepts
    • Reset
    • Interactive rebase
    • Formatted patches
    • Blame
    • Stash
    • Log filter
  • Cookbook
    • Undo
    • Branches
    • Diff
    • Stash
    • Merge
    • Hooks
    • Squashing
    • Rebase
    • Interactive Rebase
    • LFS
    • Submodules
    • Remote
    • Force push
    • Identify merged branches
    • Formated patches
    • Apply patches
    • Interactive rebase
    • Squash commits
    • Pull rebase
    • Log
    • Blame
    • Biset
    • Reset
  • Exercise
    • Exercise 1
    • Exercise 2
Powered by GitBook
On this page
  1. Cookbook

Interactive Rebase

To further organise the commits. Include -iin the command, means interactive.

git rebase -i <new-base>
  • Interactive rebase is avaialable if

    • no merged commits involved.

    • neither branch has initial commit

    • the rebase branch is not the parent (e.g. rebase master to feature won't work, but the opposite way will)

  • The text editor will open for you to select the operations on each commit.

  • The latest commit comes last on the list.

  • You can also reorder the commits during an interactive rebase.

Commonly used options

  • pick: takes the commit of one branch and puts it at the end of another branch. This is the default option for rebase.

  • reword: edit the commit message.

  • squash: combines multiple commits into one.

  • drop: removes the commit as it never happens.

PreviousRebaseNextLFS

Last updated 1 year ago