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?

5
  • 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) Commented Apr 9, 2013 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. Commented Apr 9, 2013 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. Commented Apr 9, 2013 at 22:39
  • What version of IntelliJ are you using? (because the 12th one doesn't seem too kind to git: stackoverflow.com/q/13914755/6309) Commented Apr 10, 2013 at 5:52
  • Check that the correct folder is mapped to Git in Settings | Version Control, also check this document. Commented Apr 10, 2013 at 7:23

3 Answers 3

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
Sign up to request clarification or add additional context in comments.

Comments

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'.

1 Comment

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.
3

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.