Rebase your feature branch onto master to keep a linear commit history and to apply the latest master branch changes to your work. This is a git workflow trick that looks neat in a log and causes mild panic when done accidentally on a shared branch. Follow these steps and you will be fine most of the time.
Make sure your working tree is clean. Run git status and either stash or commit uncommitted changes. This avoids surprises and also spares your future self from cryptic error messages.
Switch to master and pull the latest updates from origin so your base is current.
git checkout master
git pull --ff-only origin master
Either use checkout or switch. Take your pick.
git checkout feature-branch
# or
git switch feature-branch
Replay your feature commits on top of the updated master history. History appears linear and tidy. Clean, like someone who actually writes tests.
git rebase master
If git stops with merge conflicts open the files, fix the problems, stage the fixes then continue the rebase. If the situation gets bleak use the abort option to go back.
# after fixing files
git add path/to/file
git rebase --continue
# if things are too wild
git rebase --abort
Because rebase rewrites commits you will need to force push. Use the safer option to avoid trampling other peoples work.
git push --force-with-lease origin feature-branch
If you want to squash or edit commits while rebasing try an interactive rebase. It lets you clean up commit history before pushing.
git rebase --interactive master
If the feature branch is shared and people are basing work on it prefer merge. Rebase is best for local cleanup and making history pleasant to look at during code review. If you like surprises then go ahead. If you like coworkers then coordinate first.
Rebasing a feature branch onto master keeps history linear and brings in the latest master branch changes. The basic flow is prepare local repo, update master, checkout the feature branch, run git rebase master, resolve conflicts then push with --force-with-lease. Use interactive rebase for squashing and always communicate when rewriting shared history. Now go forth and rebase responsibly or at least convincingly.
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.