Gerrit: remote rejected (you are not allowed to upload merges) even though I allowed "Push merge commit" - gerrit

I've configured Gerrit to allow Push Merge Commit on my branch, but I still get the following error when I try to push a merge commit:
! [remote rejected] ANDROID-foo -> ANDROID-foo (you are not allowed to upload merges)
I'm running Gerrit 2.8-1-gaa9367b.

This is a bug in gerrit. The workaround is to create another reference named refs/for/refs/heads/<BRANCH_NAME>, and allow Push Merge Commit on it.
To be more specifically, add following lines in your project.config file
[access "refs/for/refs/*"]
pushMerge = group <your-id-here>

Workaround which was more suitable for me as it doesn't involve knowing branches is to allow Push Merge Commit to refs/for/refs/heads/*. You probably won't want to be doing changing these for every branch specifically.

It worked for me by this way(after this link):
git stash
git pull --rebase
git push
git pull
git stash pop

First I reset the pointer to the commit of remote using soft mode, then I run
git add .
git commit --amend
git push
It works for me. :)

Related

Heroku: ! [rejected] master -> master (non-fast-forward)

I get and error whenever I try to push rails app to heroku. What do I do to fix this? I did git init, git add ., git commit -m "complete", and git push heroku master
To https://git.heroku.com/shuabe.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.heroku.com/james.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.
Someone has committed so you have to update your brach width git pull in order to be up to date.
git fetch --all --prune
git pull origin master
Fetch will update all your branches & pull will grab the latest content into your master branch.
If you would read the error it explaining you what to do.
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes
More detailed
You are trying to push to a remote branch which has some commits that you don't have them locally in your branch. In order to push to a non-fast-forward repository you branch must have the latest updates from the remote repository.
How to grab latest updates?
git fetch --all --prune
This command will grab all the content of the whole remote repository and will update the internal git storage (pack & index files) inside the .git folder.
git pull origin master
This command will fetch & merge the remote branch into your local branch (master) and after that you will be able to push your changes.
And also you can use force argument.
git push --force heroku yourbranch:master
I fixed by:
git pull heroku master
After that, console shows:
From https://git.heroku.com/myweb
* branch master -> FETCH_HEAD
Auto-merging views/layout.hbs
CONFLICT (content): Merge conflict in views/layout.hbs
Auto-merging views/ads/list.hbs
Auto-merging controllers/users.controller.js
CONFLICT (content): Merge conflict in controllers/users.controller.js
Auto-merging config/db.config.js
CONFLICT (content): Merge conflict in config/db.config.js
Automatic merge failed; fix conflicts and then commit the result.
I accepted every change, and after that:
git push heroku master
git pull heroku main
Then
git push heroku main
The above commands worked for the question.
Then I got another error: your account has reached its concurrent builds limit (pre-recieve hook declined).
I resolved that with:
heroku restart
PS: git pull heroku main then git push heroku main should work straight up for heroku accounts that haven't reached builds limit.

Git: Merge test repository into master repository

I am new to Git/Heroku/RoR, know basics of these technologies.
I have a git repository repoA which has two branches, master and feature.
I continued working on repoA/feature and upon completion, because the changes were huge so decided to launch a separate app on Heroku to test them first.
So deployed repoA/feature to repoTest/feature on Heroku. Then made some fixes to the feature and finalized the code in repoTest/feature.
Another developer made some commits in repoA/master during this time.
Now I want to make my repoTest/feature LIVE and MERGE it to repoA/master.
Please help me how can I do that ?
NOTE: I have tried doing git rebase master but that did nothing even after a long manual conflict resolve exercise.
As below steps are my normally operations:
1. git checkout repoA/feature
2. git fetch repoTest/feature; git merge repoTest/feature repoA/feature; git stash
3. git checkout repoA/master; git pull origin
4. git checkout repoA/feature; git rebase repoA/master (maybe here you should resolve your conflicts); git stash pop
5. git status; git commit -am ""; git push origin

code push to heroku not working

I want to push code on heroku that is on gihub
I used the following command
git push heroku mybranch:master
The error is
To https://github.com/user/lyricle-new.git
! [rejected] lyricle-frt-backend -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/user/app.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and merge the remote changes
hint: (e.g. 'git pull') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Used the command git pull as mentioned in hint the response was Already up-to-date.
What could be the reasons behind this error? and is this the correct way to push on heroku
By doing git push heroku mybranch:master, you are telling git to take your local mybranch branch and merge it with the remote master branch (remotely stored on your heroku repo).
You get an error because master is ahead of mybranch in terms of commits.
Consider this example:
master: --------b---------m---------
mybranch:........\-c--c--/...........
At some point, you branch (b) master into mybranch, commit (c) some code to the branch, and merge (m) it back to master.
Now consider this example:
master: --c-----b---c-----m---c--
mybranch:........\-c--c---/.......
It is pretty much the same scenario but while you were committing code to mybranch, someone updated master by committing some other code. If you were to merge back mybranch into master, you would risk causing conflicts between your code and the new code contained in master, thus Git refuses to do the merge. First, you have to update your local branch with the new version of master and then only Git will allow you to push.
In short:
- git pull heroku master:mybranch
- resolve potential conflicts
- commit modified files
- git push heroku mybranch:master
Now about Heroku, you are supposed to always push code like this: git push heroku master (considering you are on the master branch locally). What you should do to avoid things like git push heroku mybranch:master is, when you finish working on a branch, always merge your changes to master and then (after verifying that everything is working) push master to heroku.
See this resource for a simple git workflow that seem to be what you are looking for: https://www.atlassian.com/git/workflows#!workflow-feature-branch
Everything is centralized in master eventually, and you can then regularly push master to heroku (ideally you would push once for every version of your app)
From the hints it seems that you have not pushed your latest changes to your remote repository.if you have done a pull and pushed again maybe you have removed files in your local repository that you did not remove in your remote repository.try doing a git add --all and then commit and push the changes.

Trouble pushing changes to remote Git repo

I have started learning Ruby on Rails and Git.
Whenever I try to push any changes to my remote repo on Github, I encounter the following error:
C:\Sites\first>git push origin master
To git#github.com:piy9/Twitter_clone.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git#github.com:piy9/Twitter_clone.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
NOte: I have added all the files in the directory and committed the changes. I have not created any separate branches using pull or checkout.
I am not asking for a solution to the problem.
doing
git push -f or
git push origin +HEAD
worked for me.
What I want to know is, why am I getting the error while trying to push to the original branch.
follow this and get everything works....
git branch production
git checkout production
#do some code changes
git commit -am "some desparate code changes to try fix heroku"
git push heroku production:master
Note: this will get your work done and will leave your previous branch.
or you can try this one also git push heroku +master
Looks like remote branch is ahead of yours, which means it contains something your local branch does not have. You may easily see commits on remote branch since when local branch was created or updated (assuming you run "git fetch origin/master" to fetch remote changes first):
git diff HEAD...origin/master
The output will answer your question why you are getting the error.
Now, my guess about the reason of the problem you have is that either someone has access to remote and pushed something, or you modified something using github editing interface and committed since last checkout/pull/merge. Using forced push as you did is not a good approach and it messes the history, it basically overwrites the remote branch with your copy, ignoring any remote changes.

Heroku upload changes

I make some changes in local files, how can I deploy the new version?
if I type git push heroku master, it's say everything up to date, but the application wasn't changed.
You probably need to commit your changes first.
Run git commit -a -m "updated some files"
then run git push....
So you’re on a git repo with a remote repo named heroku?
Did you commit your changes, and afterwards push?
They have to be commited locally so you can push them.
When you clone a repository with git the remote repository you cloned from will be added as “origin”, then a simple git push will push to the origin.
If that’s not the case, you can use the name of another/your remote repository you added first, or it’s URL.
Also see the doc for git push: http://www.kernel.org/pub/software/scm/git/docs/git-push.html

Resources