# git collapse commits So you want to contribute your change to your favorite open-source software. Seems pretty easy. Fork the project on github, hack hack hack, push your changes to your branch, and PR. Couldn't be simpler. Or could it? Well, if your experience with open source is anything like mine, the maintainers will have some changes they'd like you to make. You forgot to run the formatter, or they would prefer a different order of function parameters, etc. Or, you just realize additional changes you should have made. Soon, your PR looks like this: ![[bevy_cheatbook_pr.svg]] How messy! Here's how to fix it. We'll assume you have the upstream as a remote named `upstream` and want to merge your changes with the branch `main`. First, merge your branch with `main`: ``` git fetch upstream main git merge upstream/main ``` This may create conflicts and stuff, if so just fix them and commit. The next step won't work until you do. Now we want to make our git repo look like we just downloaded `upstream/main` and then made our changes. This command won't affect our code, only the local commit history: ``` git reset --soft upstream/main ``` Finally, just commit your changes: ``` git add -A git commit -m "My great PR" git push --force-with-lease ``` Voila! We now have collapsed all of our changes into one commit which can be merged without conflict.