I’m working on a Git repository, I had my branch (called jviotti) and my changes were merged to Master.
Now, after commiting some changes, I found myself unabled to push to my branch.
$ git push origin jviotti
To https://github.com/jorisbontje/pikapay-frontend.git
! [rejected] jviotti -> jviotti (non-fast-forward)
error: failed to push some refs to 'https://github.com/jorisbontje/pikapay-frontend.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.
I tried then git pull:
$ git pull
You asked me to pull without telling me which branch you
want to rebase against, and 'branch.jviotti.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.
If you often rebase against the same branch, you may want to
use something like the following in your configuration file:
[branch "jviotti"]
remote = <nickname>
merge = <remote-ref>
rebase = true
[remote "<nickname>"]
url = <url>
fetch = <refspec>
See git-config(1) for details.
After browsing a similar question here at SO, i tried:
$ git pull origin master:jviotti
From https://github.com/jorisbontje/pikapay-frontend
! [rejected] master -> jviotti (non-fast-forward)
I thought that would do the trick. What am I missing?
You should first of all make sure your local branch has the upstream branch has its upstream.
That is because the new default push policy will be “simple”.
Once that is done:
That can replay your master history on top of the
origin/jviotti(as in “What does it mean whengit pullcauses a conflict butgit pull --rebasedoesn’t?“).But after that, as in “
git pull --rebase upstream&git push originrejects non-fast-forward?“, you might still need a:The other option is to reset the local repo, as the OP jviotti comments: