DEV Community

smrpdl1991
smrpdl1991

Posted on

Step-by-Step Guide to Rebasing Your Branch onto Dev

If you want to rebase your branch onto dev instead of merging, you can use the following commands:

Fetch the latest changes from the remote repository:

git fetch origin
Enter fullscreen mode Exit fullscreen mode

Switch to your branch (if you are not already on it):

git checkout your-branch
Enter fullscreen mode Exit fullscreen mode

Rebase your branch onto dev:

git rebase origin/dev
Enter fullscreen mode Exit fullscreen mode

Again, if there are any conflicts, you will need to resolve them manually.

Push the rebased branch to the remote repository (force push may be needed):

git push origin your-branch --force
Enter fullscreen mode Exit fullscreen mode

Note : Using rebase can result in a cleaner project history, but it rewrites commit history, so be careful if you are working in a shared branch.

Top comments (2)

Collapse
 
rikesh_shrestha_60a169967 profile image
Rikesh Shrestha

Nice Article

Collapse
 
unbalanced-tree profile image
Ravi Vijay

I use TortoiseGit, which gives a better visual feel.