0

I have created an orphan branch as per the article here:

https://gist.github.com/seanbuscay/5877413

I pushed this empty branch to the remote in Bitbucket and all is good.

Then, I am cloning this branch to start a new orphan branch, as I noticed that cloning is taking a very long time which is unusual.

I am using this command to clone the orphan empty branch to start a new orphan empty branch quickly:

md testrepo
cd testrepo
git clone https://bitbucket.domain.git/<xyz> . --branch empty

There was an upgrade recently made to Bitbucket, so I am checking with the team to verify. I though to ask about this to see if there is anything I can do to speed up creating a new empty branch from the repo URL as quickly as possible.

enter image description here

torek
  • 448,244
  • 59
  • 642
  • 775
tarekahf
  • 738
  • 1
  • 16
  • 42
  • 1
    You would need to add `--single-branch` to your existing `git clone` command to make it behave the way you're expecting. However, you'd then want to undo the single-branch-ness at some point. – torek Aug 19 '22 at 12:34
  • @CryptoFool yes, this is just perfect. It's simply adding the switch `--single-branch` is what I need. – tarekahf Aug 21 '22 at 01:32
  • @torek great, this will work, what do you mean by this: `However, you'd then want to undo the single-branch-ness at some point`. Please clarify, and why I have to do that. – tarekahf Aug 21 '22 at 01:37
  • Eventually you'll want to fetch more names (and hence more commits) from the remote. To *completely* undo single-branch-ness, search StackOverflow. To add one more remote-tracking name, use `git remote set-branches --add origin `. – torek Aug 21 '22 at 17:06
  • Can you check this post please: https://stackoverflow.com/q/73454161/4180447 – tarekahf Aug 23 '22 at 06:39
  • @torek I think I faced the problem now with `--single-branch`. After I cloned that empty branch with the single branch, I tried to checkout files from another branch, but it didn't work. I had to delete the cloned branch and do another clone without the `--single-branch` switch. I believe that was what you referred to, correct? – tarekahf Sep 07 '22 at 21:10
  • 1
    Yes (well, sort of): the default `git clone` operation is to download *every* commit (technically, every *reachable* commit that the other repository offers, but that's basically "every commit"). That's what takes forever, initially. But you have to spend that time sooner or later, if you want all the commits! Git lets you delay spending the time, but at some point, it's worth just paying the price. – torek Sep 07 '22 at 21:14
  • 1
    If you undo the single-branch-ness and run `git fetch`, your Git will spend all the time needed to download every commit, even if that's days or weeks. (This can become problematic if you have a flaky network connection: Git isn't as adapted for this as some other network download software.) But once you have a clone locally, you have *everything*, and everything else goes fast. – torek Sep 07 '22 at 21:16
  • Thanks a lot! Is there a command that will remove the branch singleness right away? – tarekahf Sep 07 '22 at 22:12
  • "To completely undo single-branch-ness, search StackOverflow": https://stackoverflow.com/search?q=%5Bgit%5D+undo+single+branch – torek Sep 07 '22 at 22:27

0 Answers0