youngmon/atlassian-qna huggingface dataset:
How to pull only certain files to feature branch from main / other branches?
Asked by Shricharana Bharadwaj:

Hi,

I'm new to bitbucket and completely new to git as well. So please bear with me here.

I have a branch which I've set up as release and many feature branches. One of these feature branches has only two files, where as the release branch has many more files. (I'm using Sourcetree GUI )

After merging the feature branch for the first time, when I try to merge the feature branch after an update to its files it gives me a conflict. To resolve this, according to a tutorial video, I have to pull the release branch into feature branch in local.

The problem is, when I do this, all the files in the release branch gets added to the local branch, so I delete these files from the local branch and only keep the 2 files. Then I resolve the conflict and push the changes. But, when I'm merging this to the release branch again (through a pull request) , some how in the pull request, the rest of the files (those I deleted in local) are set to be deleted with the merge. When I do merge it, it deletes those files from the release branch leaving only two files in it.

Note that the release and feature branches are set up as different clones with different folder locations in local.

So how do I resolve this? I don't want the files unrelated to the feature branch in that branch.

Thanks in advance for any help.


Answers:
author: Patrik S
body: Hello [@Shricharana Bharadwaj](/t5/user/viewprofilepage/user-id/5261237) and welcome to the Community!

It seems that the issue is occurring because after pulling the changes from the release branch into the feature branch, you are deleting the files from the feature. When you merge the feature branch back to the release branch, git will consider the file deletions as "wanted" changes and will apply the same deletion to the release branch.

In order to just merge the changes from the feature branch to the release branch, while on the release branch, right-click on the feature branch in SourceTree and click "Merge feature into release branch". This will merge the changes from the feature branch to the release branch.

If there are any conflicts, SourceTree will prompt you to resolve them. Use a merge tool or manually resolve the conflicts in the affected files by doing the following:

* Remove the change designations added by Git

* Correct the content

* Save the file

Commit the files with resolved conflicts and push the result to Bitbucket repository.

The following articles might also be of help :

* <https://www.atlassian.com/git/tutorials/using-branches/merge-conflicts>
* <https://support.atlassian.com/bitbucket-cloud/docs/resolve-merge-conflicts/>

Thank you, [@Shricharana Bharadwaj](/t5/user/viewprofilepage/user-id/5261237) !

Patrik S


Tags: bitbucket-cloud

cloud

merge

pull-request

sourcetree
Failed to create indexes: Unsuccessful search response: 401
Asked by Bernard Jaulin:

Dear all,

I'm trying to test migration from 7.x to 8.x bitbucket release.

I'have an issue with Opensearch:

atlassian-bitbucket.log

```
ERROR [Caesium-1-4] c.a.b.i.s.i.IndexingSynchronizationService Failed to create indexes: ''[Unsuccessful search response: 401. Bitbucket did not have authorization to request data from the search server.]''
```

I followed the KB: (Done with success)

[Test button in Search server for Bitbucket server results in the access denied \| Bitbucket Data Center and Server \| Atlassian Documentation](https://confluence.atlassian.com/bitbucketserverkb/test-button-in-search-server-for-bitbucket-server-results-in-the-access-denied-858570187.html)

The test button always show "Access to the search server was denied. Check your settings."

Any idea ?

Thanks.

Bernard.

--


Answers:
author: Bernard Jaulin
body: Thank to the support.

1. Create new certificates for (Openseach only)

[Troubleshooting steps for Bitbucket Server Code Search \| Bitbucket Data Center and Server \| Atlassian Documentation](https://confluence.atlassian.com/bitbucketserverkb/troubleshooting-steps-for-bitbucket-server-code-search-827125334.html)

2. Stop bitbucket

3. Delete search folders

$BITBUCKET_HOME/shared/**search**

[Test button in Search server for Bitbucket server results in the access denied \| Bitbucket Data Center and Server \| Atlassian Documentation](https://confluence.atlassian.com/bitbucketserverkb/test-button-in-search-server-for-bitbucket-server-results-in-the-access-denied-858570187.html)

4. Restart bitbucket. Wait for some time for the initial search index creation.


Tags: bitbucket-server

server
Adicionar templates em reposit?rios do bitbucket cloud e alterar os Branch types?
Asked by Lia Andrades:

Ol?!

? poss?vel adicionar templates em reposit?rios no bitbucket cloud?

Os branchs types podem ser alterados ou adicionados? Por exemplo, adicionar os tipos "subtask" e "storybug".


Answers:
author: Patrik S
body: Hello [@Lia Andrades](/t5/user/viewprofilepage/user-id/5260875) and welcome to the Community!

By templates you mean the pipeline templates you can choose from when onboarding pipelines ? If that's the case, there's not currently a way to include your own templates, as existing templates are managed by Bitbucket engineering team.

As for branch types, you can choose from **Bugfix** , **Hotfix** , **Feature** and **Release** by navigating to Repository Settings \> Branching model. However, I'm afraid defining custom branch types is not yet available, but we do have a feature request to implement it :

* <https://jira.atlassian.com/browse/BCLOUD-10744>

I would suggest you to add your vote there, since this helps both developers and product managers to understand the interest. Also, make sure you add yourself as a watcher in case you want to receive first-hand updates from that ticket. Please note that all features are implemented with [this policy](https://confluence.atlassian.com/support/implementation-of-new-features-policy-201294576.html) in mind.

Thank you, [@Lia Andrades](/t5/user/viewprofilepage/user-id/5260875) !

Patrik S


Tags: bitbucket-cloud

cloud
Clean and force session from other devises
Asked by doungdara:

I have no Idea to force logout from other devices, Is there has anotheway that I have an ability to do this?

Pls help, thanks I'm advance.


Answers:
author: Theodora Boudale
body: Hi [@doungdara](/t5/user/viewprofilepage/user-id/1903680),

You can find details on how to do that in the following documentation:

* <https://support.atlassian.com/atlassian-account/docs/manage-recently-used-devices-for-your-atlassian-account/>

Please feel free to reach out if you have any questions!

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud
Repository size not updating
Asked by Clifford:

I have done a Repository clean up   
git reflog expire --expire=now --all \&\& git gc --prune=now --aggressive  
git push  
Its gone from 3.8GB to 4.03GB

After this but has not refreshed Repository details and is now stuck on 4.03GB unable to commit anything.

Locally it's down to around 400MB in size however it's not updating.

it's like git gc needs to be run on Bitbucket side?


Answers:
author: Ben
body: Hi [@Clifford](/t5/user/viewprofilepage/user-id/5260431)

I have taken a look at the workspace and can see two potential repositories that you may be referring to, may you please reveal the first 4 characters of the repository name so I can perform the gc from our end?

**Please note:** When we perform the gc, we will need to set the repository to **READ-ONLY** which will prevent writing to the repository while the garbage collection process occurs, this can take around 20 minutes to complete. Please let me know what time would be good to run this (with timezone).

Cheers!

- Ben (Bitbucket Cloud Support)

comments: author: Clifford
body: Hi Ben gles_app


author: Clifford
body: Is anyone from ATLASSIAN Team able to help with this?


author: Theodora Boudale
body: Hi [@Clifford](/t5/user/viewprofilepage/user-id/5260431),

I ran a git gc to your repo and its size is below the hard limit now. Please feel free to let us know if it looks ok on your end and if you need anything further.

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud
the repos are not shown when i create a new user group, i cannot select any repos as i could before
Asked by DouglasMandrake:

Hi, I got some user groups, that I usually use when I assign particular reading rights to particular repos in a project. this is done under user groups and permissions. usually, the list shows all the repos and one to select one by one and the rights. this under

Workspace Settings / User Groups and select Projects \& Repositories

in any case, this time when I create a group no repos are shown although I have plenty of repos and projects, this time, the list is not showing., please advise.


Answers:
author: Mark C
body: Hi [@DouglasMandrake](/t5/user/viewprofilepage/user-id/2906314),

Thank you for reaching out to the community.

The option "User Groups and select Projects \& Repositories" is not available anymore because we recently released [Project permissions](https://bitbucket.org/blog/project-permissions-are-available-in-bitbucket).
> To date, Bitbucket Cloud has relied on explicit permissions to grant users and groups Read, Write, or Admin (R,W,A) permission configured in each individual repository's settings. Only users or groups listed in the repository Users and Groups settings have access to that repository today. Repositories can soon have permissions explicitly configured per repository but also inherit permissions from the containing project. Permissions set within the project or the workspace implicitly apply on the repository and cannot be modified within the repository.

What this means is that you now need to configure repository permissions individually.

You can check the following links for more information:

* <https://community.atlassian.com/t5/Bitbucket-articles/Taking-Bitbucket-permission-management-to-the-next-level/ba-p/2264892>
* <https://support.atlassian.com/bitbucket-cloud/docs/configure-project-permissions-for-users-and-groups/>

Regards,  
Mark C


Tags: bitbucket-cloud

cloud
I get 'remote: Invalid credentials' whenever I try to push to my new bitbucket repository
Asked by christopher marek:

I have opened a DOS window from my local git repo. I am trying to do a push to the remote repo. A pop up ATLASSIAN comes up with user name cjmarek, and a blank box for me to input a password. I press 'Continue', and then on the dos window I see it telling me 'remote: Invalid credentials.

Password for '<https://cjmarek@bitbucket.org>  
remote: Invalid credentials

I have tried resetting my password. I am able to sign in to the bitbucket website with my reset credentials. But the DOS window to my local repo will not let me push to the remote:

<br />

git push -u origin master or   
git push origin master  

My credentials are not accepted as valid.

My email is cjmarek1@gmail.com if you want to reply to me by email.

![BitBucketProblems.png](/t5/image/serverpage/image-id/266754iE280C34FF1AEFB68/image-size/large?v=v2&px=999 "BitBucketProblems.png")


Answers:
author: Syahrul
body: G'day [@christopher marek](/t5/user/viewprofilepage/user-id/2994916)

You are using incorrect credentials, as we no longer accept account passwords for Git. You'll need to generate an App Password as your password credentials. Please check our guide below on how to generate one:

[App passwords](https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/)

I hope this helps.

Regards,  
Syahrul


Tags: bitbucket-cloud

cloud
Get Archives of files and folders using RestAPI
Asked by Gokul Rajan:

Hi Team,  

I'm trying to get a folder in my repo as zip or download a file in my repo in it's original format.  
All I could find is /src API to get meta data of folder or /src API to get content of the file.  
I could download entire Repo as zip using /get API in downloads.   

However I could not find ways to download individual files and folder from bitbucket remote Repo


Answers:
author: Patrik S
body: Hello [@Gokul Rajan](/t5/user/viewprofilepage/user-id/5260273) and welcome to the community!

While it's not directly possible to download a folder using the Bitbucket Cloud API, you can use the [Get a file or directory contents](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#api-repositories-workspace-repo-slug-src-commit-path-get) to list the files within a folder and then make additional API calls to download each file individually.

The sequence would be like the following:

* List the files in a given folder of your repository. In this example, I'm using the test_folde

  ```
  curl -u USERNAME:APP_PASSWORD https://api.bitbucket.org/2.0/repositories/workspace/repository/src/<branch>/test_folder
  ```

  <br />

  This should return a list of the files within the test_folder directory
* Iterate through the returned list of the files making an API to the same endpoint to fetch the actual content of the file.  
  Example for a file named **my_file.txt**   

  ```
  curl -u USERNAME:APP_PASSWORD https://api.bitbucket.org/2.0/repositories/workspace/repository/src/<branch>/test_folder/my_file.txt -o my_file.tx
  ```

  This API endpoint will return the raw content of the file, so we **-o** flag in the curl command to save the result into a file.

Another option, as you mentioned, is to download an archive of the entire repository at a given branch/tag, and then extract the archive and get the folder you need :

```
curl -u USERNAME:APP_PASSWORD https://bitbucket.org/<workspace>/<repository>/get/<branch or tag>.zip -o my_repo.zip
```

Hope that helps! Let me know in case you have any questions.

Thank you, [@Gokul Rajan](/t5/user/viewprofilepage/user-id/5260273) !

Patrik S

comments: author: Gokul Rajan
body: Hi [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) ,  
Thank you for your response.  

We have 1000s of files in each folder then we have to make calls individually for each files. It is a heavy process. Please take it as a feature request to download units of files and folders as zip.  

Also for current implementation may I know what is the rate limit for API in bitbucket? What would be the ideal delay between each request?  

Thank you,  
[@Patrik S](/t5/user/viewprofilepage/user-id/4603309)   

<br />

<br />


Tags: bitbucket-cloud

cloud
Integrate Jenkins with Bitbucket Cloud without using webhooks
Asked by Samuel Medina:

Good day, community!

So we have our Bitbucket Cloud, and a Jenkins server setup in a private subnet inside an AWS VPC. We're looking to integrate the two without using any webhooks in Bitbucket, as we **CANNOT** expose the Jenkins server to the public internet. We want to achieve the following:

* Publish branch build results to PRs so that we can set up a successful build merge check on PRs

So far, we've seen some plugins that can accomplish some of the functionality we want:

* <https://plugins.jenkins.io/bitbucket-build-status-notifier/> - For Build Status notifier
* <https://plugins.jenkins.io/bitbucket-pullrequest-builder/> - For Pull request polling

But we are concerned that these plugins have no recent releases in the last 3 - 4 years, and Bitbucket Build Status Notifier depends on another deprecated plugin.

We're hoping for advise on how to proceed with the integration between our Bitbucket Cloud and Jenkins without using webhooks.


Answers:
author: Theodora Boudale
body: Hi Samuel and welcome to the community!

A webhook simply sends a request to your server when an event that triggers it occurs, it doesn't create any build status updates in Bitbucket Cloud.

An application can use our API to create build status updates:

* <https://developer.atlassian.com/cloud/bitbucket/rest/api-group-commit-statuses/#api-repositories-workspace-repo-slug-commit-commit-statuses-build-post>

If there is an option in Jenkins to run something like an after-script once a build is finished and get the exit code of the build, you could use an API call in that after-script to update a commit's build status depending on the build's exit code.

You don't need to make your instance accessible from anywhere on the internet but it needs to be accessible from Bitbucket's IPs, both for polling and for running the API call. You can find the IPs used by Bitbucket Cloud here:

* <https://support.atlassian.com/bitbucket-cloud/docs/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall/>

Please feel free to reach out if you have any questions.

Kind regards,  
Theodora


author: Clifford
body: Hi Samuel  
check out <https://plugins.jenkins.io/git/>  
Set this up on a Poll SCM every min this will do what you need.  
This is what I use.

comments: author: Samuel Medina
body: Hello Clifford,

Thank you for your answer. Please note that we already have that set-up in our Jenkins. What we'd like is something that could help us send build status updates to our Bitbucket repositories without the use of Webhooks.


Tags: bitbucket-cloud

cloud
git clone not working through vs code
Asked by Akhil Kumar:

git clone <https://{username}@bitbucket.org/{workspace-id}/{repo}.git>

not working in vs code , although i am trying to correctly enter the password

\> git clone <https://{username}@bitbucket.org/{workspace-id}/{repo}.git> c:\\1Data\\Akhil\\workspace-id\\repo --progress  
fatal: Invalid credentials  
remote: Invalid credentials  
fatal: Authentication failed for '<https://{username}@bitbucket.org/{workspace-id}/{repo}.git>'

Edit: username, workspace-id, and repo named edited to protect privacy


Answers:
author: Akhil Kumar
body: I was able to clone it later. I needed to create app password in bitbucket. app password was required in vscode to clone repo

comments: author: bagarwal
body: Exactly what I was trying to say. Cool...


author: bagarwal
body: If its private repo then you need to set the user \& credentials first in VS. Please google it how to set the same.


Tags: bitbucket-cloud

cloud
Create a PR comment using Python
Asked by anton.merzliakov:

I tried to use Atlassian Python library to create a comment for my PR and failed.  

```
from atlassian import Bitbucket

bb = Bitbucket(
    url='https://api.bitbucket.org',
    username='anton_merzliakov',
    password='<app-password>')

resp = bb.add_pull_request_comment('<project>', '<repo>', '<pr-id>', 'new comment')
```

The authentication definitely works correctly because some API calls work, just not the **add_pull_request_comment**

Using a debugger I found out what happened. The server returned:

```
{
  "type": "error",
  "error": {
    "message": "Bad request",
    "fields": {
      "text": "extra keys not allowed",
      "content": "required key not provided"
    }
  }
}
```

This is the very same error message I was getting trying to create a comment manually: <https://community.atlassian.com/t5/Bitbucket-questions/Creating-a-PR-comment-via-REST-API/qaq-p/2406796> If the library itself doesn't know what keys to use, I definitely don't.

So, maybe I'm using an old version of the Python library? Maybe there's a workaround? Does Atlassian even support its Python library?


Answers:
author: anton.merzliakov
body: Patrik S told me the correct command, but I'm still curious why the Python library cannot do the same, or how to make it use this very command.

The correct manual command is

```
curl -X POST -u USERNAME:APP_PASSWORD 'https://api.bitbucket.org/2.0/repositories/<workspace>/<Repository>/pullrequests/<Pull Request ID>/comments' --header 'Content-Type: application/json' --data '{"content":{"raw":"testing one comment"}}'
```


Tags: bitbucket-cloud

cloud

python

rest-api
Webinterface out of sync with cloned version
Asked by Fokke Oosterhoff:

In my BitBucket web interface I see to commits which are not available when I do a fresh clone of this repository and switch to the right branch.

Git log doesn't show the last two commits which I do see in the BitBucket web interface. What might be the problem?


Answers:
author: Fokke Oosterhoff
body: Looks like the same issue as reported here:

<https://community.atlassian.com/t5/Bitbucket-questions/GIT-is-missing-commits-that-do-exist-on-the-Bitbucket-website/qaq-p/1984819>


author: Theodora Boudale
body: Hi [@Fokke Oosterhoff](/t5/user/viewprofilepage/user-id/3127182),

Is the issue still occurring for you? I found another report for this issue via a support ticket and the bug causing this seems to have the same root cause as the bug reported here: <https://jira.atlassian.com/browse/BCLOUD-22728>

The issue is usually fixed if we run a git gc for the repo. In case you are still experiencing this, please let me know the first two letters of the workspace id and the repo (or any other combination of letters that will help me identify it from the ones you have access to) and I can run a git gc.

If your workspace is on a paid billing plan, you can also create a ticket with the support team if you prefer that. You can create a ticket via <https://support.atlassian.com/contact/#/>, in "What can we help you with?" select "Technical issues and bugs" and then Bitbucket Cloud as product.

Kind regards,  
Theodora

comments: author: Fokke Oosterhoff
body: It looks like the same issue but the other way arround. The web-interface is showing more than the cloned version.

Issue is resolved by adding a branch.


author: Theodora Boudale
body: Hi,

The symptoms are different indeed, but the root cause seems to be the same.

It's good to hear that the issue is resolved for your repo. Please feel free to reach out if you ever need anything else.

Kind regards,  
Theodora


author: Fokke Oosterhoff
body: BTW Downloading this repository as a zip does contain these commits.


Tags: bitbucket-cloud

cloud
Repository shows wrong size
Asked by lexam-bitbucket:

Hello,

I have a git repository, under \<repo_url\>, which shows it's using 2.26GB, whereas I know it's much smaller than that (around 800MB). I've cleaned up the repository's history and tried everything to get gc to run on the server, but it doesn't seem to make a difference. A new clone using the --mirror option, followed by "git count-objects -Hv" says I'm using something short of 800MB. Can someone from Atlassian trigger GC for this repository?

Thank you


Answers:
author: Theodora Boudale
body: Hi [@lexam-bitbucket](/t5/user/viewprofilepage/user-id/971476),

I ran a git gc for your repo and its size has been reduced.

It is not possible for users to trigger a git gc on their remote repos at the moment, we have a feature request that you can vote for here: <https://jira.atlassian.com/browse/BCLOUD-11593>

Just a heads up, I removed the repo url from your post to protect your privacy.

Please feel free to reach out if you need anything else.

Kind regards,  
Theodora


author: lexam-bitbucket
body: No one?


Tags: bitbucket-cloud

cloud