基于远程分支"origin",创建一个叫"mywork"的分支。
$ git checkout -b mywork origin
git checkout -b ac_branch origin/ac_branch
git checkout <branch name> -- path 把其他分支的文件拷贝到当前分支
git clone 到本地是远程的master分支。
如果有其他分支,不会clone到本地,但可以通过 git branch -a 查看这些分支。 [或者git clone --depth=1 --no-single-branch xxxx]
如果想clone分支,要用git checkout
git checkout -b box_jb origin/box_jb
或者简化
git checkout -t origin/box_jb
当你git clone时使用了--depth 1时,checkout -b / -t时会报错:
fatal: 'origin/xxx' is not a commit and a branch 'xxxx' cannot be created from it
此时这样:
git pull <远程主机名> <远程分支名>:<本地分支名>
git checkout <hash> <filename> 取回文件的历史版本
xxx/yyy 是父子关系
xxx:yyy是兄弟关系