Novice User
Novice User

Reputation: 3824

Create only a single commit for multiple push commits in Git

I've a fork of the repo. I often create a new branch using

git branch -t -b <myBranch> upstream/master

For my local changes i do :

git commit -m "my message"

git push origin myBranch

Similarly to get the latest changes from master, I do :

git fetch upstream

git merge upstream/master

git push origin myBranch

All of the commits are the individual commits in the history, and it is often annoying. How can I keep in sync with master and yet only make a single commit of all my changes.

I've tried using git rebase -i but despite me squashing my own commits, it says merge conflicts a lot times and messes up the merge.

Upvotes: 1

Views: 250

Answers (1)

eftshift0
eftshift0

Reputation: 30212

You could do it with just one additional step... to have all your changes in a single commit. Right after merging upstream/master, do this:

git reset --soft upstream/master
git commit -m "All of my changes"

ok ok... so it was two steps. Now you can push.. but with -f because you are rewriting history

git push -f origin myBranch

Upvotes: 1

Related Questions