DEV Community

Isabella Liu
Isabella Liu

Posted on

git rebase

how to refactoring code using git rebase

I used my repo to practice git rebase. First, I created a new branch to do the changes.

git checkout -b refactoring master
Enter fullscreen mode Exit fullscreen mode

Then I tried to find some improvement in my code. I found four improvements. After I finished each improvement:

git add .
git commit -m "message"
Enter fullscreen mode Exit fullscreen mode

When I finish all my changes. I checked my commits with git log, add all the changes are in the log.

All the magic happens next step:

git rebase master -i
Enter fullscreen mode Exit fullscreen mode

And I squash all other commits which I don't need to show on the log.

// change commit message.
git commit --ament
Enter fullscreen mode Exit fullscreen mode

merge and push

git checkout master
git merge refactoring
git push origin master
Enter fullscreen mode Exit fullscreen mode

Top comments (0)