0

I have two commits : commit1 and commit2 locally.

commit1 got merged. commit2 is on top of commit1.

now, when I am trying to push commit2, it is trying to push two commits together and it gets rejected from remote saying, that commit1 has already been merged and remote rejects both the commits. my intention is to keep the changes of commit1 in commit2 and push only commit2 to masted. how can i do that?

Sourav
  • 129
  • 12
  • You push to remotes. `master` is a branch. So it's unclear what you're trying to do. Please clarify. (Perhaps you're trying to push the changes directly from a branch to the remote's `master`? But I'm not sure.) More importantly, please show exact commands and error messages, because the error you described doesn't make sense as something git would say. – Mark Adelsberger May 08 '18 at 13:42
  • 1
    $git pull --rebase .. First, rewinding head to replay your work on top of it... Applying: Commit Message 1 Applying: Commit Message 2 – Sourav May 08 '18 at 13:51
  • To ssh://gerritlink:29418/BRANCH ! [remote rejected] HEAD -> refs/drafts/master (change https://gerritlink/320934 closed) error: failed to push some refs to 'ssh://gerritlink:29418/BRANCH' – Sourav May 08 '18 at 13:51
  • $ git status On branch master Your branch is ahead of 'origin/master' by 2 commits. (use "git push" to publish your local commits) Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) – Sourav May 08 '18 at 13:51
  • locally, i am in master branch – Sourav May 08 '18 at 13:53
  • I guess I wasn't clear about this, but I don't think anybody is going to try to read the commands and output from comments; it's completely illegible and I for one am not spending time decoding it. I would recommend *editing your question to provide an appropriate level of detail* about what is happening. – Mark Adelsberger May 08 '18 at 14:11
  • Please edit your question and add all commands/outputs to it. Do not forget to add the exact "git push" command you have used. – Marcelo Ávila de Oliveira May 09 '18 at 11:24

1 Answers1

0

since commit1 already merged/pushed into remote branch it is possible to update the local branch by rebasing it. git pull -r after that the commit2 can be pushed alone on top of commit1. git push origin master:master or in case of gerrit review git push origin HEAD:refs/for/master

laplasz
  • 3,359
  • 1
  • 29
  • 40