I have a repository on github with a main branch (master) and a branch for some experimental work. I made some commits and pushed to the experimental branch and everything was fine.
Now, on a different machine, I try to clone my repository (git clone repository) and then switch to the experimental branch (git checkout branchname) but every time I do this my head gets detached and I can't push my changes. What am I doing wrong? I get the feeling I'm missing a fundamental git concept someplace but reading random git man pages isn't giving me any clues.
I'm new to git so I'm sorry if I'm being an idiot but I can't find anything in the docs that will help me reattach my head.
EDIT
The concept of a tracking branch is what I was missing. Now that I grok that concept everything is clear. Personally, I find the git branch --track
syntax to be much more intuitive than git checkout -b branch-name origin/branch-name
.
Thanks for the help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…