How to fix Merge Conflicts
Conflicts on a Pull Request
Section titled “Conflicts on a Pull Request”Conflicts can arise because many contributors work on the repository, and changes can break your PR which is pending a review and merge.
Since we squash all commits, you may not need to do a rebase. However, if a rebase is requested, check our For Usual Bug Fixes and Features or For Upcoming Curriculum and Features guides to learn how to do this process for your corresponding PR.
For Usual Bug Fixes and Features
Section titled “For Usual Bug Fixes and Features”When you are working on regular bugs and features on our development branch main
, you are able to do a simple rebase:
-
Rebase your local copy:
Terminal window git checkout <pr-branch>git pull --rebase upstream main -
Resolve any conflicts and add / edit commits
Terminal window # Eithergit add .git commit -m "chore: resolve conflicts"# Orgit add .git commit --amend --no-edit -
Push back your changes to the PR
Terminal window git push --force origin <pr-branch>
For Upcoming Curriculum and Features
Section titled “For Upcoming Curriculum and Features”When you are working on features for our upcoming curriculum next-*
branches, you have to do a cherry-pick
:
-
Make sure your upstream comes in sync with your local:
Terminal window git checkout maingit fetch --all --prunegit checkout next-python-projectsgit reset --hard upstream/next-python-projects -
Take a backup
a. Either delete your local branch after taking a backup (if you still have it locally):
Terminal window git checkout <pr-branch-name># example:# git checkout feat/add-numpy-video-questiongit checkout -b <backup-branch-name># example:# git checkout -b backup-feat/add-numpy-video-questiongit branch -D <pr-branch-name>b. Or just a backup of your PR branch (if you do not have it locally):
Terminal window git checkout -b <backup-branch-name> origin/<pr-branch-name># example:# git checkout -b backup-feat/add-numpy-video-question origin/feat/add-numpy-video-question -
Start off with a clean slate:
Terminal window git checkout -b <pr-branch-name> next-python-projectsgit cherry-pick <commit-hash> -
Resolve any conflicts, cleanup, and install dependencies and run tests
Terminal window pnpm run cleanpnpm installFCC_SUPERBLOCK='<superblock-name>' pnpm run test:curriculum:content# example:# FCC_SUPERBLOCK='python-for-everybody' pnpm run test:curriculum:content -
If everything looks good, push back to the PR
Terminal window git push --force origin <pr-branch-name>