How to Make a Private Repository from a Cloned Bitbucket Repository 

Home > Blog > How to Make a Private Repository from a Cloned Bitbucket Repository 

By: Hemanth Kumar
Published: February 13, 2025
How to Secure Your Code: Creating a Private Repository from a Cloned Bitbucket Repository

Introduction 

Managing source code repositories effectively is crucial for security, collaboration, and version control. When working with Bitbucket, you might need to create a private repository from an existing clone to protect sensitive information or limit access. This guide walks you through the steps to achieve this efficiently while ensuring seamless Jira consulting integration for issue tracking and project management.

Why Make a Repository Private? 

Making a repository private is essential for several reasons: 

  • Security: Prevent unauthorized access to your code. 
  • Compliance: Ensure that sensitive code is not publicly available. 
  • Collaboration Control: Grant access only to specific team members. 
  • Intellectual Property Protection: Keep proprietary code private. 

Step 1: Clone the Existing Repository (If Not Already Cloned) 

Using the Command Line 

Prior to cloning or interacting with a Bitbucket repository using Git, you’ll need to either: 

  • Install the Git Credential Manager (included with Git for Windows) 

You can use Sourcetree, Git from the command line, or any client you like to clone your Git repository. These instructions show you how to clone your repository using Git from the terminal. 

Clone a Repository via HTTPS 

  1. Navigate to the repository in Bitbucket and select Clone
  1. Copy the HTTPS clone command. 
  1. Open a terminal and navigate to the directory where you want to clone the repository. 
  1. Paste and execute the command: git clone https://username@bitbucket.org/your-repository.git 
      
  1. If prompted, log into Bitbucket and authorize the connection. 

Clone a Repository via SSH 

  1. Ensure your public key is added to Bitbucket and loaded on your system. 
  1. Copy the SSH clone command. 
  1. Run the following command in your terminal: git clone git@bitbucket.org:your-repository.git 
      

Using Sourcetree 

  1. Open Sourcetree
  1. Select Clone
  1. In the Clone this repository dialog, choose Clone in Sourcetree
  1. Select the destination path and bookmark name. 
  1. Click Clone. Sourcetree will create and manage the repository locally. 

Using VS Code 

  1. Open Visual Studio Code
  1. Select Clone from the repository page in Bitbucket. 
  1. Choose Clone in VS Code
  1. Install the Atlassian for VS Code extension if prompted. 
  1. Select a storage location and click Clone
  1. Open the repository in VS Code and start working. 

Step 2: Create a New Private Repository on Bitbucket 

  1. Log in to Bitbucket at bitbucket.org
  1. Click on Repositories in the top menu. 
  1. Click on Create Repository
  1. Fill in the repository details:  
  1. Repository Name: Choose a meaningful name. 
  1. Repository Type: Select Git or Mercurial. 
  1. Privacy: Select Private to restrict access. 
  1. Click Create Repository to finalize the setup. 

Step 3: Update the Remote URL to Point to the New Private Repository 

After creating the private repository, update your cloned repository to push changes to the new private repository. Run the following command to set the new remote repository: 

git remote set-url origin https://bitbucket.org/your-username/new-private-repository.git 
  

To verify the new remote URL, run: 

git remote -v 
  

This should display the updated remote pointing to the new private repository. 

Step 4: Push Code to the New Private Repository 

To transfer all existing code from the cloned repository to the new private repository, run: 

git push -u origin –all 
  

This command pushes all branches to the new repository. Next, push all tags: 

git push -u origin –tags 
  

This ensures all versioned releases are also moved to the new private repository. 

Read more: Accelerating Team Productivity with Atlassian Intelligence 

Step 5: Verify the New Private Repository 

Once the push is complete, navigate to your new private repository on Bitbucket and confirm: 

  • All files and branches are present. 
  • The repository is marked Private
  • Only authorized users have access. 

Step 6: Manage Repository Access (Optional) 

You can control who has access to your private repository by: 

  1. Navigating to Repository Settings
  1. Selecting User and Group Access
  1. Adding specific users or teams and assigning permissions (Read, Write, Admin). 

Also read : Jira Reporting and Analytics

Conclusion 

By following these steps, you have successfully created a private repository from a cloned Bitbucket repository. This ensures that your code remains secure, access is controlled, and sensitive information is protected. Whether using Git CLI, Sourcetree, or VS Code, managing your repositories properly is a best practice for security, compliance, and efficient team collaboration. 

About MicroGenesis 

MicroGenesis, a leading Atlassian Platinum Partner and the Best IT Company, provides expert solutions for DevOps, Agile, and IT Service Management. With extensive experience in Bitbucket, Jira, and CI/CD integrations, we help organizations streamline software development, improve collaboration, and enhance security. Our team of experts offers end-to-end support, including repository management, security best practices, and automation strategies to help businesses achieve operational excellence. Contact us to learn more about how we can optimize your Bitbucket environment for efficiency and scalability.

Related Articles