This article is directly ported from my personal blog.
Imagine that there are two pull requests open on a project repository.
Each change has its own branch like this:
The challenge is to use git rebase to add both changes to master. When you finished, your master branch should have three commits in the following order:
- feat: add user-agent endpoint
- feat: add base64 endpoint
Okay, let’s go!
git clone repo_url git status git checkout feature/add-base64-endpoint git rebase master git status git checkout master git merge feature/add-base64-endpoint git status git checkout feature/add-user-agent-endpoint git rebase master
Oops! You should see
You need to check the code and fix it. Fortunately VS Code provides great hints for you to do that.
I'd rather recommend vim though because I'm also an huge fan of VIM!
Do not forget to check the all the code is functionable once you resolve the conflict, i.e. all the tests should be green, app should be functional finally.
Once you finish resolving it, Continue like so:
git add . git rebase --continue git checkout master git status git checkout master git merge feature/add-user-agent-endpoint git status git log
Boom! You must be done!
Happy gitting! 😉