If you want to merge a feature branch into master without turning version control into a soap opera, this guide walks you through the command line steps. You will learn how to update master, perform the merge, resolve conflicts, test locally and clean up branches. No drama, just git merge and a little common sense.
First make sure master matches the remote baseline that will receive the merge. This avoids surprises and angry CI pipelines.
git checkout master
# or
git switch master
git pull origin master
Pulling ensures your local master has the latest commits from origin. If you skip this, you might merge into an outdated history and then explain yourself to the team.
Now bring the feature branch into master. You can merge while on master. Fast forward merges happen when master has no recent commits, which is Git being lazy in the best way.
git checkout master
git merge feature-branch
If you want to force a merge commit even when a fast forward is possible, use git merge --no-ff feature-branch
. That preserves a visible branch point in history for posterity or for future archaeologists.
Merge conflicts are not personal. They mean two changes touched the same lines. Learn the pattern and move on.
git status
to list conflicted files.<<<<<<< HEAD
, =======
, and >>>>>>>
.git add
and git commit
.git status
# edit the files to resolve conflicts
git add .
git commit
If an automated merge tool helps you sleep at night, use it. If not, manual edits will do fine as long as you test afterward.
Run unit tests, build steps and a quick manual check. If that passes, push master so others can enjoy your handiwork.
git push origin master
Pushing updates the remote and triggers CI if you have it. If CI fails, fix it on a branch and repeat the merge once green.
Once the branch has served its purpose remove it to avoid a cluttered repo that looks like a jungle after a developer convention.
git branch -d feature-branch
git push origin --delete feature-branch
That is the workflow. Update master, run the merge, handle conflicts, validate everything and clean up. Do this enough times and merging will feel like a predictable routine rather than a gamble. Now go merge something and pretend you had a plan all along.
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.