I’m working on a project where I forked a GitHub repo and made some changes. The original repo accepted my changes and added more stuff. Now I want to get those new changes into my fork without messing things up.
I tried doing a pull and then a push, but it ended up duplicating my commits. That’s not what I want. Is there a better way to keep my fork in sync with the original repo? I’m kind of new to this and could use some help figuring out the right steps.
Here’s what I’ve done so far:
git clone my-forked-repo
cd my-forked-repo
git add .
git commit -m "Made some changes"
git push origin main
After that, the original repo merged my stuff. Now I’m stuck on how to get their new changes without doubling up on commits. Any tips would be great!
Ensure you’re on your main branch:
git checkout main
Merge upstream changes:
git merge upstream/main
Push to your fork:
git push origin main
This method should bring in new changes without duplicating commits. It’s a good practice to do this regularly to keep your fork updated; if you encounter merge conflicts, you’ll need to resolve them manually before pushing.