ajoo Posted December 24, 2017 Share Posted December 24, 2017 Hi all Below is an image of my git with labels. As you can see there are 3 branches and a master. I created the branch B3 from B2 and B2 from B1 but i guess for git all seem to come from the master ulimately ( I mean the trunk of the tree is common to all). The pen-ultimate commit comes from the production server. I then cloned that into my local machine where I wish to develop and test locally. That is the basic idea - to develop and test locally and then push to the repo. From there pull the changes to the server and run it there. Continue to develop and test locally and then push again to repo. Then pull the changes to the server and continue the cycle. So I made a small test change and pushed it to the repo. All is fine. However when I pull the branch into the server, it wants to merge B2 into B3 which is not what I intend to do. I just want to continue to develop along B3 and leave B2 alone where it is. Is this possible? Is there a better way to achieve what I am trying to? Thanks all. Quote Link to comment Share on other sites More sharing options...
requinix Posted December 24, 2017 Share Posted December 24, 2017 Sounds like you're testing in production. I think I've said to use a branch before. If so I take it back. Don't do that. Checkout detached branches. $ git checkout --detach origin/B3origin/B3 will reference a particular commit (currently b0aaaca) and that will get checked out. You won't be able to make commits or other changes, but in production that should be fine. Quote Link to comment Share on other sites More sharing options...
ajoo Posted December 25, 2017 Author Share Posted December 25, 2017 Hi, The suggested command gives the following error : fatal: git checkout: --detach does not take a path argument 'origin/B3' Thanks Quote Link to comment Share on other sites More sharing options...
requinix Posted December 25, 2017 Share Posted December 25, 2017 Then that means origin/B3 isn't a valid reference. "B3" has to be a branch name. If you want a tag then it's tags/B3. Or you might need a git fetch. That's not included in a checkout like it is with a pull. Quote Link to comment Share on other sites More sharing options...
ajoo Posted December 25, 2017 Author Share Posted December 25, 2017 (edited) hmm it says does not take a path argument and not that it's an invalid reference Could it be that it's considering origin/<branch_name> as a path (as echoed by the message ) which it seems not to allow? Still stuck. Maybe I should just delete the copy of the repo on the server and then try and get the detached head from the repo as you suggested. What do you think ? Thanks. Edited December 25, 2017 by ajoo Quote Link to comment Share on other sites More sharing options...
ajoo Posted December 25, 2017 Author Share Posted December 25, 2017 OK this seems to do it right: clone --depth 1 --branch <branch name> <git URL> Thanks requinix. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.