Let's say you're working with feature branches. I know Trunk based development is the way to go, but hear me out. If your team is using git flow, this will help you get out of a sticky situation.
If two people are collaborating on the same feature branch, and one person rebases the branch with main/master and pushes to origin, then the other person will face a load of conflicts when pulling the branch from origin (because of the new rebased commits). Here's how you can refresh your local branch completely:
- π π’π πππππ‘ π¨π«π’π π’π§ ππ‘π-ππ«ππ§ππ‘ (fetch branch from origin)
- π π’π π«ππ¬ππ --π‘ππ«π π¨π«π’π π’π§/ππ‘π-ππ«ππ§ππ‘ (reset local branch and point to origin)
This will update your local branch with the one in the remote. However, if you already made some changes in your own local branch and the other teammate has rebased it, here's what you can do
Scenario A -> If you already committed the changes, in that case you can just do this:
- π π’π πππππ‘ π¨π«π’π π’π§ ππ‘π-ππ«ππ§ππ‘ (fetch remote branch)
- π π’π π«ππππ¬π π¨π«π’π π’π§/ππ‘π-ππ«ππ§ππ‘ (rebase your local with the remote)
Scenario B -> If you were just working on some changes but you did not commit them yet, you can simply
- π π’π π¬πππ¬π‘ (To stash your local changes)
- follow the initial 2 steps to refresh the local branch
- π π’π π¬πππ¬π‘ π©π¨π© (to get your local changes back)
- continue your work!
Top comments (0)