Problem with “divergent branches” after creating IntelliJ project and pushing to new Bitbucket repository

I am trying to push a new IntelliJ project into a new Git repository on Bitbucket, but it fails with a “divergent branches” message. I really want to use IntelliJ and not step out to the command line for basic version control actions, but it doesn’t seem possible.

This is what I have done:

  1. I created a new repository in the Bitbucket web application
  2. I created a new project in IntelliJ: A Kotlin project with Gradle
  3. In IntelliJ, I selected VCS / Enable version control integration
  4. In IntelliJ, I went to Git / Manage remotes and added a new remote using the URL from the Bitbucket Clone button.
  5. In IntelliJ: Git / Fetch
  6. In IntelliJ: Git / Pull: Now I get the “You have divergent branches and need to specify how to reconcile them” message.
  7. I ran this on the command line: git config pull.rebase false
  8. At this point I get into a loop about “divergent branches” or that “main has no tracked branch”.

I am using: IntelliJ IDEA 2024.1.5 (Ultimate Edition)

2

It seems that you have created one or more commits in bitbucket and in IntelliJ, i.e. locally. And since both start from an empty repository, they don’t have a common ancestor and therefore can’t be merged as on would normally do.

Depending on where you start you have various options how to get out of this:

  1. Avoid creating any commits in Bitbucket or IntelliJ before setting up git and the remote.
    This should avoid the whole problem completely. I haven’t used Bitbucket in ages, but I guess it allows to create stuff like READMEs on repository creation. These are introduced by commits, which will cause the problems you described.

  2. if you have commits on both sides and already tried the stuff you mentioned above follow this process to

    a) fix the situation

    b) understand what is going on.

    1. open the Git view in IntelliJ (CMD-9 on MacOS)

      You should see two branches. Probably called main and origin/main containing the local and remote commits respectively.

    2. Use IntelliJ to check out origin/main and create a new branch. I assume you name it work for now. Make sure that branch is checked out.

    3. In the Git view select the oldest local commit and cherry-pick it. Repeat for all local commits, starting with the oldest. Repeat for all local commits.

    4. Checkout main again. Perform a reset to work. Choose hard when asked how to perform the reset.

  3. Now perform a git push on main.

All commands of course can be performed on the command line, and I actually recommend using the command line a lot for Git. Because it is faster, in my opinion often easier to understand, and I’m old.

Also you should be able to do the same thing with rebase but I have a hard time remembering the correct arguments for these cases.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Problem with “divergent branches” after creating IntelliJ project and pushing to new Bitbucket repository

I am trying to push a new IntelliJ project into a new Git repository on Bitbucket, but it fails with a “divergent branches” message. I really want to use IntelliJ and not step out to the command line for basic version control actions, but it doesn’t seem possible.

This is what I have done:

  1. I created a new repository in the Bitbucket web application
  2. I created a new project in IntelliJ: A Kotlin project with Gradle
  3. In IntelliJ, I selected VCS / Enable version control integration
  4. In IntelliJ, I went to Git / Manage remotes and added a new remote using the URL from the Bitbucket Clone button.
  5. In IntelliJ: Git / Fetch
  6. In IntelliJ: Git / Pull: Now I get the “You have divergent branches and need to specify how to reconcile them” message.
  7. I ran this on the command line: git config pull.rebase false
  8. At this point I get into a loop about “divergent branches” or that “main has no tracked branch”.

I am using: IntelliJ IDEA 2024.1.5 (Ultimate Edition)

2

It seems that you have created one or more commits in bitbucket and in IntelliJ, i.e. locally. And since both start from an empty repository, they don’t have a common ancestor and therefore can’t be merged as on would normally do.

Depending on where you start you have various options how to get out of this:

  1. Avoid creating any commits in Bitbucket or IntelliJ before setting up git and the remote.
    This should avoid the whole problem completely. I haven’t used Bitbucket in ages, but I guess it allows to create stuff like READMEs on repository creation. These are introduced by commits, which will cause the problems you described.

  2. if you have commits on both sides and already tried the stuff you mentioned above follow this process to

    a) fix the situation

    b) understand what is going on.

    1. open the Git view in IntelliJ (CMD-9 on MacOS)

      You should see two branches. Probably called main and origin/main containing the local and remote commits respectively.

    2. Use IntelliJ to check out origin/main and create a new branch. I assume you name it work for now. Make sure that branch is checked out.

    3. In the Git view select the oldest local commit and cherry-pick it. Repeat for all local commits, starting with the oldest. Repeat for all local commits.

    4. Checkout main again. Perform a reset to work. Choose hard when asked how to perform the reset.

  3. Now perform a git push on main.

All commands of course can be performed on the command line, and I actually recommend using the command line a lot for Git. Because it is faster, in my opinion often easier to understand, and I’m old.

Also you should be able to do the same thing with rebase but I have a hard time remembering the correct arguments for these cases.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật