Reputation: 10030
I have made some changes to a local repository and would like to commit these on top of the latest changes to the remote repository. Normally, I could do something like:
# Stash away my changes
git stash
# Fetch and apply the remote changes. I do not want a merge.
git fetch
git checkout
# Apply my changes on top of the remote changes
git stash pop
# Commit and push
git add changed.txt
git commit
git push
But now I made the mistake of committing my changes. Is there an easy way of stashing away my commited changes for a while, like git stash
does for uncommitted changes?
Upvotes: 1
Views: 2321
Reputation: 219920
No need to stash. You can use git rebase
to achieve what you're after:
$ git fetch
$ git rebase origin/master
$ git push
This will automatically replay your changes on top of the remote branch.
Upvotes: 2