So from what I understand, after I've made a pull request and it has been merged, GitHub creates a "Merge Commit" to signify this.
However, if I make another pull request down the line, even after merging the merge commit into my local fork, it shows all of the commits from previous pull requests as well.
The only way I can seem to get around this is directly after having a pull request merged, resetting my local head to the original repo's merge commit in GitKraken, and then force-pushing to my fork.
The issue is, this feels like it's a very wrong way of doing things. Is that true? And if so, how should I be going about it instead?
Force pushing usually means something isn't quite right.
It sounds like you aren't updating your local upstream branch after you hit the merge button on GitHub.com.
git checkout master
git pull --all
git checkout -b feature-branch
git add stuff
git commit -m "cool feature"
git push origin feature-branch
<click merge on GitHub.com>
git checkout master
git pull --all -p
git branch -d feature-branch
<see refs move, your feature branch get cleaned>
If you branch again from this point, you won't see the "cool feature" commit in later PRs since your local master has it.
After you merge, run
git pull --all -p
to update your local repo with all the remotes and their refs.
-p
will also prune merged branch refs to clean up your tab complete list.
So, the sequence usually goes:
git checkout master git pull --all -p ; This should update your local master unless it differs from upstream if you do have local changes on master, you should either push them, or through them away.
if you want to throw them away, and make your master a copy of the upstream on
git reset --hard origin/master
will make the current local branch a copy of the remote ref.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With