This is more of a clarification question. In Gitlab, you can create multiple branches from the same repository, so the repository myrepository.git can have a master branch and then a development branch for example.
When I clone the repository to a local repository, I often do a single branch and not the whole repository with all of the branches like
git clone <url> --branch development --single-branch
If I am working on multiple branches, I then create a separate directory for each of the branches. My reasoning is that this seems cleaner since I will know what branches I am working in and there's no easy way to switch between the branches and sync up the files. Am I doing this incorrectly? Is there a reason why you would want to have multiple branches in the same directory?
Thanks.
In some version control systems (and some workflows) what you are saying makes perfect sense, because you only have a small number of long-lived branches.
An often repeated advantage of git over earlier versioning systems is that "branches are cheap", leading to workflows where it is common to create and delete multiple branches, every single day . It commonly looks like this:
All of this relies on branches being easy to create, and easy to switch between, which is no longer true if you tie each directory to a named branch.
Thank you everyone for your help. After some experimentation, I believe I was initially mistaken when I tried out Gitlab, so my procedure was based on a wrong assumption. I did something like this:
Further experimentation was unable to duplicate this behavior. Git checkout worked and if you made changes to the file, it will warn you to commit, just as I expected. I think perhaps the VPN was not running at the time, which is needed to connected to the Gitlab repository, though I would think I should have gotten a timeout when I run git checkout, so I am not still sure what happened.
Just to let everyone know that what I asked was not necessary. There is no need to setup separate directory for each branch.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.