10

So I just installed and set up my first Git repo.

I came across that error while trying to push an update. What I tried to do:

  1. See an error - Fix it
  2. Click 'VCS' at the top
  3. Hover 'Git'
  4. Click 'Commit File...'
  5. Fill in comment. Make sure the file I changed in selected
  6. Click 'Commit and Push' at bottom of screen
  7. Hilight all the files I wish to push
  8. Click 'Push' at bottom of new screen

What is the issue here and what can I do to resolve it?

Makoto
  • 104,088
  • 27
  • 192
  • 230
  • Does your git repo have somewhere to push to? Like a remote? IntelliJ can also get out of sync with the disk (just right click your top level directory and click Synchronize) – Daniel Williams Apr 09 '13 at 22:28
  • I just set up git. I don't follow you when you say 'remote'. Also, I should mention, now whenever I commit, it doesn't show the latest commit in the Git Push dialog. –  Apr 09 '13 at 22:33
  • Update: I just did a push through Git Bash and all the files updated. Even though some were listed as 30 minutes old. –  Apr 09 '13 at 22:39
  • What version of IntelliJ are you using? (because the 12th one doesn't seem too kind to git: http://stackoverflow.com/q/13914755/6309) – VonC Apr 10 '13 at 05:52
  • Check that the correct folder is mapped to Git in `Settings | Version Control`, also [check this document](http://wiki.jetbrains.net/intellij/Using_Git_Locally). – CrazyCoder Apr 10 '13 at 07:23

3 Answers3

16

When you push to an empty repository you must set on checkbox "Push current branch to alternative branch" and choose master as that alternative. It's because master is not created yet (repo is really empty). But doing this way you can pretend to initialize the repository.

While that checkbox is off and repository is empty, IDEA can't push, because its interface must be safe and he will not just create new brach if the one in which you pushed last accidentally disappeared (or just not exist). You must force that "branch creation"

UPD By the way currently latest IntelliJ versions can push to a nonexistent branches. Now it's shown just with adding prefix '+' to the name of branch in origin.

In the Push Commits dialog it looks like

bugfix/PML-239 -> origin:+bugfix/PML-239
AlpenDitrix
  • 322
  • 2
  • 8
4

I've resolved this with turning on checkbox "Push current branch to alternative branch". Not sure, but we need this for first push to new branch as it have status as 'untracked'.

paka
  • 1,601
  • 22
  • 35
  • Yeah this works fine, i have a git repository on bitbucket.org, and people have suggested to install some plugins from bitbucket into intellij, but by simply checking this option on the initial (first) commit it worked. no need to install extra plugins, and dont need to check this option for the next pushes. – Mateus Viccari May 24 '14 at 12:52
3

In my case, after setting up my remote repository, I simply made a fetch and then the push worked just fine.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
aragorrn
  • 31
  • 1