0

The command git clone --single-branch allows us to clone just a single branch, instead of pulling everything at once. For large repositories, this can significantly improve performance. For us, it cuts down waiting time in half when doing checkouts, commits, rebases, logs, etc.

Due to our environment configuration, it is not possible to drop the entire git repository and re-clone it. So, I'm wondering how I can achieve the same performance improvements of only cloning and maintaining only the master branch with git clone --single-branch, but without deleting the repo and re-cloning it with the --single-branch parameter.

wohlstad
  • 12,661
  • 10
  • 26
  • 39
andrew
  • 521
  • 1
  • 7
  • 14
  • [This is](https://stackoverflow.com/a/17714718/7976758) how one undoes single-branch clone; nothing fancy. Perhaps you can revert the solution: `git config remote.origin.fetch "+refs/heads/master:refs/remotes/origin/master"`. Then delete local excessive branches and do maintenance (garbage collection). – phd Jan 29 '21 at 16:59
  • [phd's comment](https://stackoverflow.com/questions/65958116/how-to-acheive-the-same-effect-as-git-clone-single-branch-without-re-cloning#comment116619977_65958116) contains the answer to the question you asked. However, doing or undoing single-branch-ness generally mostly just has a one-time cost or benefit in terms of space and performance. That is, once you have a full clone, it's rare to see it slow down much just *because* it is a full clone. It's not impossible, but I wouldn't expect much improvement. – torek Jan 30 '21 at 05:57

0 Answers0