Apologies for how basic this is..but remotely, I have a master branch and a dev branch I’m working on. I check out the master like this:
git clone https://github...
and I can check out the dev branch like this:
git clone -b my-branch https://github...
Previously, I had both branches cloned locally in the same directory and i could see them listed with
git branch
I acheived this by building the dev branch locally and then pushing it to the server. Then (to experiment) I deleted everything to see if I could recreate the setup whereby I have both the master and my dev branch in the same directory and I could switch between them.
Also, as I develop, I want to check what the dev branch looks like on my local server, and then switch to see what the master branch looks like on my localserver. How is this problem normally solved please? Do I need to have each branch in a seperate directory and start the server in that directory?
Thanks in advance
If you
git clonetwice into different locations, well, you don’t really use branching the way it was intended.You should
git clonejust once, and then you cangit checkoutto whatever branch you want. By default, aftergit clone, you will have just one local branch (probablymaster), but you can explore which branches are present on server bygit branch -av. You can also checkout to server branch bygit checkout --track origin/another-branch– this will create local tracking branchanother-branch.At any rate, you should really invest some time in reading good git book, for example Progit.