When git decides to throw a tantrum and stops mid pull you need to know if a merge is in progress. Run git status
and look for messages about a merge conflict or an ongoing merge sequence. This is the calm before the debugging storm.
git status
If a merge sequence is active the first and least risky move is to abort it. Use git merge --abort
to roll back to the state before the pull started. This usually gets you out cleanly and fast.
git merge --abort
Sometimes git merge --abort
will complain or the bad merge was already committed. In that case fetch the remote branch then force your branch to match it. Warning this will discard local changes so be sure you have saved anything important.
git fetch origin
git reset --hard origin/branch-name
If you have any local edits worth keeping stash or branch them first. Stash gives you a temporary safe place while creating a new branch gives you a named refuge for later digging. Both options beat explaining to your team why you nuked hours of work.
git stash push -m "save before undo"
# or
git checkout -b save-my-work
If the merge was already committed and you need to rewind the timeline git reflog is your time machine. Inspect the recent history and pick a safe entry. Then reset to that commit to restore your branch to the desired point.
git reflog
git reset --hard HEAD@{2}
git status
to confirm a merge in progressgit merge --abort
first for a low risk rollbackgit reset --hard origin/branch-name
as a last resortgit reflog
to recover commits if neededgit status
and git reflog
Merge conflicts are the universe's way of reminding you that computers are honest and humans are reckless. Follow the steps above and you will undo most git pull disasters without crying into your keyboard. If you do end up crying your keyboard will understand but stash first.
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.