Monday, 30 September 2013

Pushing to remote after locally rebasing commits

Pushing to remote after locally rebasing commits

Im using a private github repo for a project on which I'm the sole developer.
Yesterday, after pushing my latest changes to github, I decided to try my
hand at rebasing some of my local commits to clean things up a bit. I
followed Github's rebase tutorial and did not heed the warning at the top:
Warning: It is considered bad practice to rebase commits which you have
already pushed to a remote repository. Doing so may invoke the wrath of
the git gods.
After squashing some commits, I tried a push, and got this:
$ git push origin master
To git@github.com:me/my-repo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:me/my-repo.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
Ok, it wants me to merge remote changes, but I haven't made any so I'll
ignore that. Looking at the help section, it looks like I have the option
to force a push with:
git push --force
Considering no one else has touched the remote repo between my last push
and the rebasing, is that what I should do?

No comments:

Post a Comment