Keep Your Branch in Sync
Why Your Branch Falls Behind
Imagine this situation: you create a branch called feature/absolute from main and start working on a new feature. Meanwhile, a teammate finishes their own work and merges it into main. Now main has moved forward with new commits, and your branch is still based on the older version of main - the one from before your teammate's changes.
Here's what the history looks like at this point, before any merge or rebase:
C---D feature/absolute
/
A---B---E main
You branched off at B and made commits C and D. Meanwhile, your teammate added commit E to main. The two branches have diverged.
When you're done and try to merge your branch back into main, Git needs to combine two different histories: the commits your teammate added and the commits you added. To do this, Git creates what's called a merge commit - a special commit whose only purpose is to tie these two histories together. It doesn't contain any new code of its own; it just says "these two lines of work are now joined."
Here's what the history looks like after a merge:
C---D feature/absolute
/ \
A---B---E---M main
A and B are commits that existed before you created your branch. You branched off at B and made commits C and D on feature/absolute. Meanwhile, your teammate added commit E
Learn Git in a Day
Everything you need, nothing you don'tEnroll now to unlock all content and receive all future updates for free.
Hurry! This limited time offer ends in:
To redeem this offer, copy the coupon code below and apply it at checkout:
