Sometimes I want to be able to pull from a repo (via clone). But when I do that and then change to a local branch to pull-in a remote branch, git assumes I want to take the main branch and integrate it. How do I avoid this? I’m sure I can achieve what I want by a different series of actions/commands.
I’d say I normally run into this when I want to work on a specific branch on a secondary machine.
update:
I run the following commands on a secondary machine where I only want to work on the experiment branch
git clone http://somewhere.com/something.git
git branch experiment
git checkout experiment
git pull origin experiement
Each branch needs to point at some commit. If you don’t specify anything,
git branchpoints the new branch at at the same commit as HEAD.You want the branch to point at
origin/experimentinstead:or…
or, since git is smart enough to know what you’re trying to do in this case…
All of these will do the same thing (create the new branch pointing at
origin/experiment). They’ll also set the branch up to trackorigin/experiment, so push and pull will be to and from that remote branch.