Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git / gerrit, push remote rejected no changes made

Tags:

git

gerrit

Made changes to a commit, performed commit amend. Do a push and I get the error:

! [remote rejected] master -> refs/for/master (no changes made) 

Checked the change ID in the commit message and its still a valid commit.

I've tried changing a file, checking it shows up as an alteration and then added to staging area and done another commit amend. Try the push again and getting the same issue. No idea on this one.

Edit: This is pushing to gerrit, not git directly.

I'm running:

git push origin master:refs/for/master 

And the result of getting the details of origin are (with company details edited out):

$ git remote show origin * remote origin   Fetch URL: ssh://[email protected]:29418/myrepo   Push  URL: ssh://[email protected]:29418/myrepo   HEAD branch: master   Remote branch:     master tracked   Local branch configured for 'git pull':     master rebases onto remote master   Local ref configured for 'git push':     master pushes to master (up to date) 
like image 973
edwardmlyte Avatar asked Dec 21 '12 14:12

edwardmlyte


People also ask

Why is Github rejecting my push?

Sometimes, Git can't make your change to a remote repository without losing commits. When this happens, your push is refused. If another person has pushed to the same branch as you, Git won't be able to push your changes: $ git push origin main > To https://github.com/USERNAME/REPOSITORY.git > !

Can you amend commit after pushing?

About amending a commit Amending a commit is a way to modify the most recent commit you have made in your current branch. This can be helpful if you need to edit the commit message or if you forgot to include changes in the commit. You can continue to amend a commit until you push it to the remote repository.

How do you commit changes to a remote control?

To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.


1 Answers

This issue is due to the actions I'd performed previously. I was trying to push a new change, on top of a change which was still up for review, who's parent also was up for review.

 Trunk ------ Parent A ----- Parent B ----- New change (merged)     (unmerged)     (unmerged) 

I had used cherry-pick to obtain these two changes locally (Parent A and Parent B), and then a third cherry-pick to get my change from a local branch before attempting to push. That is what caused the issue, because my personal change was essentially trying to re-write history.

The correct process would be to only pull Parent B when at trunk. This automatically pulls up any commits between trunk and it (in this case just Parent A). Then cherry-pick my new change on top of that and push will work fine.

like image 118
edwardmlyte Avatar answered Oct 06 '22 14:10

edwardmlyte