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

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

Diego Alcántara August 28, 2020

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
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 31, 2020

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
AUG Leaders

Atlassian Community Events