Rebasing a Feature Branch in Eclipse EGit: A Step‑by‑Step Guide
Rebase a feature branch onto the latest upstream commit in Eclipse EGit. Follow this step‑by‑step guide to reset, rebase, resolve conflicts, verify, and recover if needed.
25 Oct 2025, 03:55 UTC

Desired Outcome
Recreate a linear commit history on the target branch by replaying the commits from your feature branch onto the latest upstream commit. After the rebase, the feature branch pointer should sit at a new tip that contains all of its original commits, but now positioned after the most recent commit on the target branch. No merge commits should appear between the two branches.
Prerequisites
- Eclipse IDE 2025‑09 or newer (EGit 5.0+).
- EGit plugin installed and enabled.
- Project checked out from a Git repository.
- Clean working tree – no uncommitted changes or staged files.
- Feature branch already created and checked out locally.
Procedure
- Reset the target branch (optional but recommended). If you want to ensure the target branch points to the latest upstream commit, switch to it in the
Git Repositoriesview, right‑click<target‑branch>and chooseReset…. In the dialog, selectHardreset and confirm. This discards any local changes on the target branch.# From the command line if you prefer git checkout <target-branch> git fetch origin git reset --hard origin/<target-branch> - Switch to your feature branch. Right‑click the branch in the
Git Repositoriesview and selectCheckout. - Start the rebase. Right‑click the feature branch again, choose
Rebase…. In theRebasedialog, set theUpstreamfield to<target‑branch>(e.g.,origin/master) and clickStart Rebase. The dialog will list the commits that will be replayed. - Resolve conflicts. If conflicts arise, the
Conflict Resolverwill open. Use the editor to resolve each file, then mark the conflict as resolved. After each resolution, clickContinue Rebasein the dialog. - Complete the rebase. Once all commits are applied, the dialog will show a success message. Your feature branch now points to a new tip.
Verification Checks
- Git History view. Open
Git Historyfor the feature branch. The log should display the feature commits in order after the latest commit on<target‑branch>. - Command‑line confirmation. Run:
git branch -v # should show <feature-branch> at the new tip git log --graph --oneline --decorate --simplify-by-decoration | grep <feature-branch> # the graph should be linear, no merge markers between branches - No merge commits. Verify with:
git log --graph --oneline --decorate | grep merge # No output indicates no merge commits between the branches
Recovery Options
- Abort the rebase. If you hit an impasse, open the
Rebasedialog and clickAbort, or run:
This restores the feature branch to its state before the rebase started.git rebase --abort - Restore from a backup commit. If you performed a hard reset on the target branch and need to recover, locate the pre‑reset commit in the
Git Repositoriesview, right‑click it, and chooseReset…withHardagain.
Limitations & Cautions
- Older EGit versions may use slightly different dialog names; always confirm the options match the description above.
- Hard resets discard uncommitted work on the target branch; ensure you have backups or have committed any important changes before proceeding.
- Rebasing rewrites commit history. If the feature branch is shared with others, coordinate with teammates before pushing the rebased branch.
Practical Example
Assume you’re on a feature branch feature/awesome‑feature and want to rebase it onto origin/main:
- Reset
origin/mainlocally:git checkout main git fetch origin git reset --hard origin/main - Switch to the feature branch:
git checkout feature/awesome‑feature - Start the rebase via EGit:
- Right‑click
feature/awesome‑feature→Rebase…. - Set
Upstreamtoorigin/main. - Click
Start Rebase.
- Right‑click
- Resolve any conflicts, then continue.
- After completion, verify with
git log --graph --oneline --decorate.
Push the rebased branch (force push may be required):
git push --force-with-lease origin feature/awesome‑feature
Force‑push only if you’re certain no one else is basing work on the old history.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.