bitbucket works fine in command line, but not work with intellij
Asked by John Sheng:

Hi,

I set up bitbucket account, and use intellij, and 100 project (in folder C drive).

1. for testing purpose  
I copy 2 project (2 folders) from C drive to D drive, and I am able to use command line to commit/pull/push/clone code between laptop and bitbucket.

git clone <https://code.xxx.com/scm/wdextend/wdextend-repo.git>  
REM make change  
git add .  
git commit -m "v2"  
REM KGS make change  
git pull  
REM found conflict  
REM resolved conflict  
git add .  
git commit -m "after merged"

git push origin master

2. I have hard time to configure intellij

I follow this instruction [IntelliJ Idea Integrated with Bitbucket Repository \| by Sahil Tiwari \| Medium](https://medium.com/@sahiltiwari_66376/intellij-idea-integrated-with-bitbucket-repository-33331bcde924), but either the tuotirla is outdated, or my intellij has issue, I didn't see VCS in top menu. I see "git".

when I try to push or pull, I got following error

13:19:03.414: \[wcpExpense\] git -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/master:master --tags  
error: failed to push some refs to '<https://code.deliverybackbone.amr.xxx.com/scm/wdextend/wdextend-repo.git>'  
hint: Updates were rejected because the tip of your current branch is behind  
To <https://code.deliverybackbone.amr.xxx.com/scm/wdextend/wdextend-repo.git>  
! refs/heads/master:refs/heads/master \[rejected\] (non-fast-forward)  
hint: its remote counterpart. Integrate the remote changes (e.g.  
Done  
hint: 'git pull ...') before pushing again.  
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

<br />

POST git-upload-pack (327 bytes) From <https://code.deliverybackbone.amr.xxx.com/scm/wdextend/wdextend-repo> \* branch master -\> FETCH_HEAD = \[up to date\] master -\> origin/master refusing to merge unrelated histories

Is there a tutorial I should follow?

Thank you very much!  
John


Answers:
author: Pramodh M
body: Hi [@John Sheng](/t5/user/viewprofilepage/user-id/4789294)

Before making the push, see if sync option or pull option is present and select that sync the changes from remote to your checked out repository in local.

Thanks,  
Pramodh

comments: author: John Sheng
body: Hi [@Pramodh M](/t5/user/viewprofilepage/user-id/3691224)

Thank you for your reply.

when I do pull from intellij, I got this error:

POST git-upload-pack (327 bytes) From <https://code.xxx.xxx.com/scm/repo> \* branch master -\> FETCH_HEAD = \[up to date\] master -\> origin/master refusing to merge unrelated histories


author: Erez Maadani
body: Hey [@John Sheng](/t5/user/viewprofilepage/user-id/4789294)

Is it possible the intellij project is in a different location/path from the project you are using in the CLI?

Based on past experience, when you are opening an existing project which is already tracked by git, the git plugin will identify it and will suggest you to allow it to "take-over" and then by reading the .git directory, it will have all the info it needs: head, branches, tags, etc'.

Another option, you can go to "File" -\> "New" -\> "Project from Version Control...", add the repo url, and specify the target directory. ++**Do note to use a different directory from your current project**++. This will create a new project, cloned from the git repo so the HEAD and histories will in sync with your remote.


author: John Sheng
body: Hi [@Erez Maadani](/t5/user/viewprofilepage/user-id/5018344) Thank you for your help. I tried you "another option", and got "the directory already exist and is not empty" error.

is there any tutorial? I watched this video, 8 years old, and it seems to be outdated:[Setting up Bitbucket and IntelliJ - YouTube](https://www.youtube.com/watch?v=klfLSRXUOzY)

I also download this intellij plug in [Bitbucket Linky - IntelliJ IDEs Plugin \| Marketplace (jetbrains.com)](https://plugins.jetbrains.com/plugin/8015-bitbucket-linky). I have no luck to make it work.

as that said, I am able to make bitbucket work from command line.


author: Erez Maadani
body: Hey [@John Sheng](/t5/user/viewprofilepage/user-id/4789294)

The error is because you are trying to create a project in a directory which already contains a project. Try again with a new directory.


author: John Sheng
body: Hi [@Erez Maadani](/t5/user/viewprofilepage/user-id/5018344)   
I use IntelliJ in past years, and I have about 100 projects which already exist in current diretory. my goal is to push these 100 to bitbucket. is it right that I need to create a new directory, moving these 100 existing projecs, then push them to bitbucket?


Tags: bitbucket-cloud

cloud