Hacker News new | past | comments | ask | show | jobs | submit login

Fun fact: you can clone a repo on your local disk... to another location on your local disk.

  > git clone file://<ABSOLUTE_PATH> [<CHECKOUT_NAME>]
And once you have a bunch of local checkouts, you can use them as a sandbox for trying out random distributed git workflows.



This will save me a lot of time. I'm always hopping between branches on the single repo we use to stay in the free-tier. I couldn't find this in the Git documentation, but it works great!


I'm a little confused how re-cloning a local clone helps you compared to cloning the original remote repo. You can certainly have multiple clones of the remote repo in multiple locations on disk. To avoid name collisions, you can just not clone to the same parent directory, or choose an alias: `git clone <URL> <ALIAS>`.

However, if cloning your monorepo and switching branches takes a long time, consider `git worktree`. This set of commands allows you to clone a repo once, then keep multiple branches checked out at the same time, in different directories. See this, for example.[1]

[1] https://spin.atomicobject.com/2016/06/26/parallelize-develop...


Thanks, that's even better. I need to work on my Git skills, I'll try this out.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: