This short and mildly opinionated git tutorial explains how to merge master into a feature branch in GitLab using basic git commands. Follow these steps to keep your work compatible with the main line of development and to reduce merge conflicts and flaky CI runs. No magic. Just a tiny bit of effort and fewer emails demanding urgent fixes.
Get the freshest master so you do not inherit other peoples drama. This reduces surprise conflicts and keeps your feature branch sane.
git checkout master
git pull origin master
Move back to the branch you are actually working on. Use the command you like better. Confirm you are on the right branch before you start merging anything.
git switch feature-branch
# or if you prefer the older command
# git checkout feature-branch
git status
Bring the main line changes into your branch so your code stays compatible and CI does not hate you. This is the classic merge workflow in version control and in GitLab based projects it keeps the pipelines predictable.
git merge master
Conflicts happen when two changes touch the same lines. That is life. Open the conflicted files, resolve the markers, and make a sensible decision. Then mark the files resolved and commit.
# edit conflicted files in your editor
git add path/to/conflicted_file
git commit -m "Resolve merge conflicts between master and feature-branch"
Before you push, run your test suite and static analysis. Catching problems locally prevents noisy pipelines on GitLab and saves reviewers time. If CI is green locally then you have a much better chance of getting a smooth merge request review.
After resolving conflicts and validating locally push your branch and open a merge request on GitLab. Describe what you merged and which tests you ran. If there are manual steps for reviewers mention them up front.
git push origin feature-branch
Follow this workflow to keep feature branches aligned with master, avoid messy merge conflicts, and stop pipelines from exploding at 3 am. You will not be a git hero overnight but your future teammates will thank you.
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.