Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pushing tags with git rejected as non-fast-forwarding

Tags:

git

Git pull works doesn't show any updates:

sh-3.2$ git pull
Already up-to-date.

When I do a git push I get an error:

sh-3.2$ git push --tags
To [email protected]:some/git/repo
 ! [rejected]        DEVEL_BLEEDINGEDGE -> DEVEL_BLEEDINGEDGE (non-fast-forward)
error: failed to push some refs to '[email protected]:some/git/repo'
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.

Rebasing gives the same:

sh-3.2$ git pull --rebase
Current branch devel is up to date.

The DEVEL_BLEEDINGEDGE tag is used on my daily automated build scripts, everytime I need to deploy some new stuff with those scripts I move that tag with:

git tag -f DEVEL_BLEEDINGEDGE

So, why can't I push my tag back?

I get this error every now and then for other tags which I don't move also.

like image 250
Cleber Goncalves Avatar asked Mar 15 '13 11:03

Cleber Goncalves


People also ask

How resolve Git push rejected non-fast-forward?

If you do a commit in one project and then accidentally push this commit, with bypassing code review, to another project, this will fail with the error message 'non-fast forward'. To fix the problem you should check the push specification and verify that you are pushing the commit to the correct project.

What does non-Fast-forward mean in Git?

A non-fast-forward merge is a merge where the main branch had intervening changes between the branch point and the merge back to the main branch. In this case, a user can simulate a fast-forward by rebasing rather than merging.

Why is my Git push being rejected?

A commit gets rejected and causes a failed to push some refs to error because the remote branch contains code that you do not have locally. What this means is that your local git repository is not compatible with the remote origin.

How do you push without fast forward?

Enter --force. This option overrides the “fast forward” restriction and matches our local branch to the remote branch.


1 Answers

It looks like you want to move the tag. Tags are designed to mark a specific state of your project, like release 1.0. This shouldn't be changed on daily basis. If you want to change (move) a tag anyway, you can do it using the -f (force) switch twice:

git tag -f TAG_I_MOVE
git push --tags -f

In your case I would use branches to mark the "developer bleeding edge"

git branch -f DEVEL_BLEEDINGEDGE HEAD
git push --tags

Here no "-f" switch for push needed, as long as you move your DEVEL_BLEEDINGEDGE branch forward within the same history path.

like image 152
Boris Brodski Avatar answered Sep 22 '22 15:09

Boris Brodski