23

I am using git inside netbeans IDE. I wanted to change the commit message for the most recent commit I had made. I did that, checked the amend last commit checkbox and committed it to my local repository. When I push this commit to my github repo, I get the error: git remote repository contains commits unmerged into the local branch. open output to see more information. How do I fix this ? I am new to source control. I only want to do very basic version control with my current project. Please tell me how to fix this.

Screen:

enter image description here

Output message:

git branch
git remote -v
setting up remote: origin
git submodule status
git push https://github.com/double-whammy/netbeans_affablebean.git refs/heads/master:refs/heads/master
Remote Repository Updates
Branch Update : master
Old Id        : id1
New Id        : id2
Result        : REJECTED_NONFASTFORWARD
Local Repository Updates
Branch Update : origin/master
Old Id        : id1
New Id        : id2
Result        : NOT_ATTEMPTED
==[IDE]== Pushing - AffableBean finished.
james
  • 1,667
  • 5
  • 26
  • 38

7 Answers7

40

I read the error message once again and thought that I should merge the local branch into remote branch. I looked around in the IDE to find these options. I got lucky when I tried: Project > right click > Git > repository browser.

The following window opens up:

enter image description here

Steps:

  1. Remote branch > right click > merge revision. Then you will see the hash of remote next to local.

  2. Project > Right click > Git > Remote > Push. This will push your local branch code to remote repo.

james
  • 1,667
  • 5
  • 26
  • 38
11

Realize a pull. Then a window with the option 'merge' will appear. Do a merge and try to push it again.

Sorry for my english level

v-system
  • 111
  • 1
  • 2
  • This also worked for me. My problem was I created a README.md file before I did a push from Netbeans. I deleted the README, but it just saw there were commits remotely that it didn't have so didn't allow me to push until I pulled first. But yeah maybe I should do Daniel's suggestion in another answer to fetch then merge instead. I like to see whats happening. – Michael K Nov 13 '17 at 23:09
9

Don’t use git pull, use git fetch, then git merge, then git commit and then git push.

FYI: http://longair.net/blog/2009/04/16/git-fetch-and-merge/

Daniel De León
  • 13,196
  • 5
  • 87
  • 72
1

If you can not see the file under remote in the git repository browser then first you need to pull in order to solve the above problem.
Steps:
1.Right click project > Git > Remote > Pull > then select merge option.
2.Right click project > Git > Remote > Push.
The problem should be solved by now :-)

Aman Lahariya
  • 305
  • 3
  • 11
0

Right click your project > Git > Remote > fetch Right click your project > Git > Branch/ tag > Merge Revision Click merge Now u should be able to do the push...

0

I would delete the repository. Recreate the repository. Please don't commit anything. Then push it after adding and committing inside NetBeans. Remember, you can create README.md, anything later.

chikitin
  • 762
  • 6
  • 28
0

Though it's already solved. just want to post it down here. I had the same error as yours but it happened because i modified my repository in github and didn't pull it to my local repository.

you need to remote > pull and then choose rebase.

that's what i did

Super Kai - Kazuya Ito
  • 22,221
  • 10
  • 124
  • 129