Git is driving me mad. I forked a github repo and added some changes, then realised that I had made my changes on top of some commits after master.
In my local copy of the repo, I reset master
back to upstream/master
and then cherry picked the changes. Like this:
My change is "Add support for directed advertising mode". As you can see I accidentally did it on top of upstream/scheduling_policy
instead of upstream/master
.
The problem is when I try and push this, I get this error:
git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags --set-upstream origin master:master
Pushing to https://github.com/Timmmm/ble.git
To https://github.com/Timmmm/ble.git
... lots of [up to date]s ...
= [up to date] v2.5.2 -> v2.5.2
= [up to date] v2.6.0 -> v2.6.0
= [up to date] workingOldBootloader -> workingOldBootloader
! [rejected] master -> master (non-fast-forward)
Can someone tell me the totally intuitive command that I need to make it move the origin/master
branch to my local master
branch?
Ah I think the reason for the cryptic error "non-fast-forward" is that Git is worried that I'll lose the origin/master
commit if I move it, since no other branches point to that.
You can tell Git that you actually want that by using a force push:
git push -f
Unfortunately this isn't implemented in SourceTree for reasons that nobody has even tried to explain (it's "dangerous", "always a mistake" and "not what you want").