skip to content
Logo Castle's Blog

git 常用命令--切换分支

  • 拉取命令

git pull

  • 推送命令

git push

  • 切换远程分支 并创建本地同名分支

git switch -c <branch> origin/<branch>

branch为分支名称 尽量保证这两个一样

  • 列出本地和远程的所有分支

git branch -a

  • 需要刷新远程分支列表时,先拉取远端信息再查看:
Terminal window
git fetch --all
git branch -a
  • 下载克隆仓库 (在gitlab上 点击clone可以查看地址 优先选择ssh地址)

git clone <仓库地址>