Ugh. So Dropbox has just caused me a couple of issues thanks to it not syncing when it should have. I don't know whether to merge
or rebase
or something else. I need some advanced gitfu.
I'm the only developer on the project and the conflict appeared because of switching between my desktop and laptop. Nobody else works with this repo... I could literally wipe the remote repo and start again and it would be fine. (I don't really want to lose the history, but it would be fine from a code POV.)
Running git push
simply says:
To github.com:JCW/kicker-ticketing.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:JCW/kicker-ticketing.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
git status
reveals:
On branch master Your branch and 'origin/master' have diverged,
and have 6 and 3 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working tree clean
I've deleted all the conflicted files (including the ones in .git/
and manually added all the code changes) -- my local repo is now what should be the remote origin/master
.
What is the best way, in this particular solo-dev situation, to just push my local repo to become the new remote origin/master
?
I've read a few guides on rebase vs merge, but still the obvious solution eludes me.
Next time I will make sure that Dropbox hasn't crashed before continuing to work. Sigh.
You say:
my local repo is now what should be the remote origin/master
If you are sure in that, to reset the remote state from your local state just run git push -f
. This is destructive for the remote end, so it is nice if you backup that first.
As a solo developer (and in small teams) I prefer to use git pull --rebase
to keep the linear history at all times, because it is then easier for me to debug issues like that one.