If your repo had feelings it would probably file restraining orders against merge conflicts. They are inevitable but not invincible. This guide walks through a calm and slightly sarcastic path to fetch changes merge branches and resolve conflicts on the command line or with a merge tool. Follow the steps and avoid becoming the office legend who broke main.
Always start by getting the latest remote state. This prevents surprises and passive aggressive PR comments.
git fetch origin
git status
git fetch origin updates remote tracking branches. git status confirms your working tree is clean. If you have uncommitted changes stash them or commit them before continuing.
Checkout the target branch where the merge will land. Typical targets are main or develop.
git checkout target-branch
Replace target-branch with the branch name you actually use. Yes you can type faster but do not make typos here.
Bring the other branch in. If Git is feeling generous this will be automatic. If not you will be introduced to conflict markers.
git merge source-branch
If the merge completes with a nice quiet message you are lucky and may celebrate quietly. If not you will see conflict messages and changed files listed by git status.
When Git cannot reconcile the changes it injects conflict markers into the file. They look like this.
<<<<<<< HEAD
...your current code...
=======
...incoming code from source branch...
>>>>>>> source-branch
Your job is to pick, edit, or combine the bits so the file reads like sane human code again.
You have two main options. Fix them manually or use a visual merge tool for mercy.
If you prefer less keyboard therapy use a GUI tool. VS Code merge editor Meld and many IDEs will show both sides and let you choose hunks. Configure a graphical tool if you like pretty diffs.
Once the files read correctly stage them and finish the merge.
git add path/to/file1 path/to/file2
git commit
git push origin target-branch
Git commit will complete the merge commit. Use a clear message that explains what you chose and why. Future you will thank present you or at least whisper forgiveness.
Merge conflicts are not personal attacks. They are just code trying to be important. Keep calm fetch often and make your commit messages good enough for future archaeologists. If you must, blame the test that caught the problem and move on.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.