Skip to content

Instantly share code, notes, and snippets.

@JoelLau
Created December 22, 2021 09:02
Show Gist options
  • Save JoelLau/c4e3b53fad80d8796673342240a54724 to your computer and use it in GitHub Desktop.
Save JoelLau/c4e3b53fad80d8796673342240a54724 to your computer and use it in GitHub Desktop.

Git Help

Resolving Git Merge Conflicts With Rebase

  1. pull latest commit to main branch
git checkout main

# pull latest meta-data
git fetch --all

# bring changes to local branch
git pull
  1. go back to feature branch
git checkout <feature-branch-name>
  1. attempt to put main branch changes BEFORE feature branch ones
# make sure the current branch is the feature branch
git rebase main
  1. type git status to view next action

  2. (optional) depending on whether or not there was conflict, you might need to resolve merge conflicts

  • make code changes in vscode
    • go to git tab
    • click the refresh button
    • make code changes before hitting '+' on the conflicted files
    • run git rebase --continue upon git status recommendation
  1. since the history was changed, git push will no longer work, instead use:
# WARNING! This is a potentially destructive action - use with care!
git push --force-with-lease
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment