Your branch and main diverge
Your branch feature/cart has two commits. Beto added another to main. git fetch downloads it: only origin/main moves, now at d5e72ab. The graph shows the divergence: your commits start at 1264b56.
Your branch feature/cart has two commits. Beto added another to main.
git fetch downloads it: only origin/main moves, now at d5e72ab.
The graph shows the divergence: your commits start at 1264b56.
Your branch feature/cart has two commits. Beto added another to main. git fetch downloads it: only origin/main moves, now at d5e72ab. The graph shows the divergence: your commits start at 1264b56.
git rebase origin/main sets your commits aside and changes your base.
It replays them one by one: a45c681 comes back as 2c8e0f3, a new commit.
Same change and message, but another parent: so the hash changes.
git rebase origin/main sets your commits aside and changes your base. It replays them one by one: a45c681 comes back as 2c8e0f3, a new commit. Same change and message, but another parent: so the hash changes.
The second commit clashes: Beto and you changed the same line of config.js.
The rebase stops at that commit. git status tells you where it is.
Here HEAD is the new base: "ours" is origin/main and "theirs" is your commit.
The second commit clashes: Beto and you changed the same line of config.js. The rebase stops at that commit. git status tells you where it is. Here HEAD is the new base: "ours" is origin/main and "theirs" is your commit.
Keep Beto's cost and your free shipping, then mark it with git add.
No git commit: git rebase --continue replays it as 5d1dad6.
Your old commits are not deleted: they are still on origin/feature/cart.
Keep Beto's cost and your free shipping, then mark it with git add. No git commit: git rebase --continue replays it as 5d1dad6. Your old commits are not deleted: they are still on origin/feature/cart.
A normal git push is rejected: non-fast-forward.
Do not run git pull: it would bring your old commits back.
A normal git push is rejected: non-fast-forward. Do not run git pull: it would bring your old commits back.
git push --force replaces the remote branch without asking anything.
If a teammate had pushed a commit, --force would delete it.
--force-with-lease compares: it is no longer at b4c6c0a, so it refuses.
git push --force replaces the remote branch without asking anything. If a teammate had pushed a commit, --force would delete it. --force-with-lease compares: it is no longer at b4c6c0a, so it refuses.
In this example nobody pushed anything: the remote branch is still at b4c6c0a.
--force-with-lease replaces it, and the Pull Request updates itself.
In this example nobody pushed anything: the remote branch is still at b4c6c0a. --force-with-lease replaces it, and the Pull Request updates itself.
Rebase replays your commits on top of origin/main: a linear history, new hashes.
Golden rule: never rebase a shared branch. On your own, --force-with-lease.
Rebase replays your commits on top of origin/main: a linear history, new hashes. Golden rule: never rebase a shared branch. On your own, --force-with-lease.