Reputation: 10632
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
Upvotes: 0
Views: 304
Reputation: 116197
If you git clone
twice into different locations, well, you don't really use branching the way it was intended.
You should git clone
just once, and then you can git checkout
to whatever branch you want. By default, after git clone
, you will have just one local branch (probably master
), but you can explore which branches are present on server by git branch -av
. You can also checkout to server branch by git checkout --track origin/another-branch
- this will create local tracking branch another-branch
.
At any rate, you should really invest some time in reading good git book, for example Progit.
Upvotes: 1
Reputation: 1500
I don't know if I get you right :) But If you cloned some repo you got it as master branch. Then if you wanted to have the same repo as another branch you didn't have to clone it seperatly :) all you needed to do is to do:
git checkout -b branch_name
and it would branch your master. Then you could push either your master or branch_name to REMOTE branch master or create new remote branch branch_name and i think this is what you wanted. But there is another way with cloning into a branch, which is usefull if you want to clone let us say REMOTE branch A to your LOCAL branch B, that means if you want to cross them :) But to answer your question if you didn't push your branch to remote repo it disappeared unfortunately. I will recomend that you read some documentation: http://git-scm.com/documentation about branching and checking out it really helps to get the idea of git.
Upvotes: 0