clone
-
先从远程仓库克隆项目
git clone https://github.com/ATQQ/time-control.git
-
clone 成功
-
切换进入项目目录
cd time-control
如图:
-
查看clone下来的本地分支
git branch
可以看到,我们只clone下来了一个
main
(主)分支
同步远程其他分支
-
但有的时候,我们需要其他分支的代码
-
先查看全部分支(包含本地和远程分支)
git branch -a
-
然后同步其他远程分支:
git checkout -b 本地分支名 origin/远程分支名
# 创建本地分支 feature/interactive 并与 远程分支 feature/interactive 同步 git checkout -b feature/interactive origin/feature/interactive
如下图,提示:已切换到新分支
feature/interactive
,同时新分支已与远程分支feature/interactive
保持同步 -
这时,就已经完成了与远程分支的同步,如果之后的工作中,远程分支的代码有了更新,那么可以用
git fetch
和git merge
再次进行同步