git创建新分支并push到远程服务器

1. 切换到被copy的分支(master),并且从远端拉取最新版本
    $git checkout master

$git pull
2. 从当前分支拉copy开发分支,例如我要创建新分支v2为例
    $git checkout -b v2

Switched to a new branch 'v2'
3. 把新建的分支push到远端
    
$git push origin v2
4. 拉取远端分支
   $git pull
   There is no tracking information for the current branch.
   Please specify which branch you want to merge with.
   See git-pull(1) for details.

   git pull <remote> <branch>

   If you wish to set tracking information for this branch you can do so with:
   git branch --set-upstream-to=origin/<branch> v2
   经过验证,当前的分支并没有和本地分支关联,根据提示进行下一步:
5. 关联
  $git branch --set-upstream-to=origin/v2

注意:这里branch之后都是没有空格的,如果有空格则是错误命令
6. 再次拉取 验证
    $git pull

使用Git下载指定分支命令为:git clone -b 分支名仓库地址

使用Git下载v2分支代码,使用命令:git clone -b v2 http://192.168.16.16:3000/codeAdmin/kg_web_api.git 如下图所示:

原文:https://blog.csdn.net/QH_JAVA/article/details/77760499

扫描二维码关注公众号,回复: 4644945 查看本文章

猜你喜欢

转载自blog.csdn.net/qq_32502511/article/details/84239360