demagogue on 1/9/2017 at 13:12
Urgh, I could strangle git.
If any of you know it, could you help me.
I'll try to be brief here.
I've been using gitbash to make a blog on github.
Today I wanted to use it to make some other website also on github (in another repository, i.e., another url).
The first time I did it, I must have flubbed something because the other website unintentionally pushed to my blog's github repository.
Because it's such a pain & to not deal with switching repositorites, I'm just going to make that other website some other non-git-involved way. So I just want to get gitbash back to updating my blog and forget that other website ever existed as far as gitbash & github are concerned.
When I try to push the blog now, though, I get the error:
$ git push origin master
to https://[git url for my blog]
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://[git url for my blog]
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.
So, fast-forwards is telling me how I can integrate the new changes (for the other site) into my local whatever to allow me push my new stuff in (with the other site stuff added too). I don't want to do that. I want all the new changes (the other site) to disappear as if they never existed and it revert back and let me push the blog as it is now as usual. Or even that wouldn't be bad, as long as I can get back to pushing my blog back in.
The tutorials are not being helpful. Does anybody know how I can do this?
Edit: Ok fine...
$ git push origin master --force
did the trick for my purposes.
I swear... How they managed to create a system so obtuse and deserving of a strangling at every turn...
Nameless Voice on 1/9/2017 at 14:01
It looks like you've already found the solution. Basically, if you want to replace / erase a commit on origin, you need to force push.
Some more general advice:
Download and use (
https://github.com/gitextensions/gitextensions) GitExtensions.
Git is awesome, but it's very obtuse, and far too complex to use effectively from the command line.
What you need when using source control like that is a very clear picture of exactly what state it's in and what you're doing, which is hard to get from the terminal tools, but really easy to see in a GUI if you know what to look for.
GitExtensions is a really good GUI which usually shows you the relevant information or the options you might want to choose for any operation.
For example, if you tried to do a destructive push like you were trying to do there, it would explain what's wrong and give you options including to force it if you're sure that's what you want.
It's primarily for Windows, but you can also run it on Linux with Mono (though it's a little buggy there.)
I use git all the time at work and can heartily recommend this tool.