DEV Community

Discussion on: An Introduction to Git Rebase: A Tutorial

Collapse
 
michaelcurrin profile image
Michael Currin • Edited

Note that if you are rebasing on a remote master, you have to do a pull first, as in the tutorial. Which is tedious to do regularly.

git checkout master
git pull
git checkout my-feat
git rebase master
Enter fullscreen mode Exit fullscreen mode

You can also do it this way, without updating local master.

git checkout my-feat
git fetch
git rebase origin/master
Enter fullscreen mode Exit fullscreen mode

Or simply, in even fewer commands

git checkout my-feat
git pull --rebase origin master
Enter fullscreen mode Exit fullscreen mode

Then do

git push 
Enter fullscreen mode Exit fullscreen mode

Implied to be

git push origin my-feat
Enter fullscreen mode Exit fullscreen mode

Note that all the approaches here have the same outcome. And they are safe to do repeatedly and doesn't require a force push. As they only rebase unpushed commits, which is the golden rule of rebasing. See article for more info that rule.

Collapse
 
za-h-ra profile image
Zahra Khan

This is amazing, thank you!