How do i perform a git rebase?
shoebill last edited by shoebill
Link for understanding rebasing from git documentation: https://git-scm.com/book/en/v2/Git-Branching-Rebasing
Quote from git documentation: "Do not rebase commits that exist outside your repository and people may have based work on them."
Note: The general advice is you should know what you are trying to achieve when using this command.
The diagrams are from git documentation, their demo shows different branch names.
If you create a branch from master in your local, for example named crufts2020 and start making changes, those changes will be divergent from the master.
Create a branch from master branch.
$ git checkout -b crufts2020 Switched to a new branch 'crufts2020'
Start making some changes. in crufts2020 and your commit history should look something like this:
Rebase changes from crufts2020 branch on master branch.
$ git rebase master First, rewinding head to replay your work on top of it... Applying: Added another perl script for staging
After the rebase your commit history should look something like:
Perform a fast-forward merge on master.
$ git checkout master $ git merge crufts2020 Updating 0f307e7c9b..d6d7656542 Fast-forward myperl5.pl | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 myperl5.pl
After the fast-forward merge your commit history should look something like:
All commits have been replayed onto master and both branches now point to the same commit.
© Lightnetics 2019