Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is it possible to fork a repository but only one branch? Edited

We've a repo with 3 branches, 2 (master, develop, these are the git-flow branches for the legacy project) of which are going to be deprecated in the near future, I'd like to know if it's possible to fork the repository only for the remaining branch, which will become the "develop" branch in the new repo.

I would keep only the last N commits (i.e. 100) on the reamining branch because it's based on the legacy branches, having lots of heavy unnecesary .jar files, so I'd like also to have a lightweight repo (as every maven / gradle project should ideally be)

 

Thanks in advance for your thoughts,

Diego.

1 answer

0 votes

Hi Diego,

I'm afraid that it is not possible to fork a certain branch of a repository only or specify the number of commits you want from this branch.

One thing you can do is fork the repo, switch the main branch of the fork to "develop" from the repository Settings, and then delete the other two branches of this fork. I would also suggest contacting our support team (via https://support.atlassian.com/contact/#/) to run a git gc on the fork after you delete the branches, otherwise the commits of the deleted branches will remain on the repo as dangling commits. (I can also run a git gc if you feel comfortable sharing the URL of the repo here)

Would you need to sync the fork with the parent repo? If you won't need to sync the fork with the parent repo, another suggestion I can make is to clone only the last 100 commits of develop branch with a command like the following:

git clone repo_url --branch develop --depth 100

Then create a new repository in Bitbucket Cloud and push from that clone.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,804 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you