I can't push, non-fast-forward

Hello,
(I’m french so I’m sorry if it’s not lisible)

I got a problem with

git push

I got this error :

fatal: The current branch wave_generator has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin wave_generator

So i use the command git tell me to use but now I have this error :

 ! [rejected]        wave_generator -> wave_generator (non-fast-forward)
error: failed to push some refs to 'https://github.com/DeveCout/Racoon-Hut.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.

I don’t really know what is fast-forward, I see it has something to do with fetch and merge : but I don’t want to merge the 2 branch since it’s not finished !
I’m new with git so I don’t get it : I have branch (master and wave_generator), I did’nt finish all the wave_generator part. So I don’t understand the need of merge :confused:

For the context : I work on 2 computer, I have push with the one will working on the other one, and I’m trying to push both of them.

Thanks for taking time to help me ^^

It looks like there is already a wave_generator branch in your repository on GitHub, but it wasn’t configured as the upstream branch of the wave_generator branch on the computer you’re trying to push from. That got fixed with the --set-upstream option.

However, the remote wave_generator branch seems to contain commits that aren’t on your local branch. That’s what “Updates were rejected because the tip of your current branch is behind its remote counterpart” means. I assume you made those commits on your other computer.

Now you need to tell Git how to make the remote and local commits fit together. Common ways would be to merge the remote commits into your local wave_generator branch, or rebase your local commits on top of the remote branch. Merging to main is often reserved for complete features, but in general merging is done whenever you need to bring two branches together, like your local and remote wave_generator branches here.

Check chapter 3 of the Git Book (the link goes to the French version) for details on how to work with branches, including merging and rebasing.

1 Like