首页 > 其他分享 >git本地分支创建后关联远程分支

git本地分支创建后关联远程分支

时间:2023-09-06 11:37:46浏览次数:40  
标签:git name -- branch upstream 远程 分支


在使用git创建本地分支时,可以在创建分支时就设置好跟踪的上游分支:

git checkout -b local_branch -t upstream_name/remote_branch

$ git checkout --help

       -t, --track
           When creating a new branch, set up "upstream" configuration. See "--track" in git-branch(1) for details.


           If no -b option is given, the name of the new branch will be derived from the remote-tracking branch, by looking at the local part of the refspec
           configured for the corresponding remote, and then stripping the initial part up to the "*". This would tell us to use "hack" as the local branch when
           branching off of "origin/hack" (or "remotes/origin/hack", or even "refs/remotes/origin/hack"). If the given name has no slash, or the above guessing
           results in an empty name, the guessing is aborted. You can explicitly give a name with -b in such a case.


如果在本地分支时忘了关联上游分支,可以在创建好上游分支后使用命令:

git branch --set-upstream-to=upstream_name/remote_branch

$ git branch --help

       -u <upstream>, --set-upstream-to=<upstream>
           Set up <branchname>'s tracking information so <upstream> is considered <branchname>'s upstream branch. If no <branchname> is specified, then it defaults
           to the current branch.

标签:git,name,--,branch,upstream,远程,分支
From: https://blog.51cto.com/u_16248677/7384641

相关文章

  • git修改已经push了的commit message
    1gitcommit--amend2gitpush-fgitpush--help    -f,--force      Usually,thecommandrefusestoupdatearemoterefthatisnotanancestorofthelocalrefusedtooverwriteit.Also,when--force-with-leaseoption      is......
  • C#远程调用WebService
    ///<summary>///远程调用WebService///</summary>///<paramname="url">以wsdl结尾的url地址</param>///<paramname="method">要调用的方法名</param>///<paramname......
  • 【git】git拉取项目报错
    1、报错现象>gitpull@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@WARNING:REMOTEHOSTIDENTIFICATIONHASCHANGED!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ITISPOSSIBLETHATSOMEONEISDOINGSOMETHINGNASTY!......
  • 开发软技能——Git Commit规范
    提交代码是程序员们每天的工作日常,今天敬姐给大家分享一个好的编程习惯,就是关于GitCommit规范。效果预览<type>(<scope>):<subject><BLANKLINE><body><BLANKLINE><footer>提交之后的效果如下:GitCommit语法type:必填commit类型,有业内常用的字段,也可以根据需要......
  • git 同步上游仓库新分支
    git-如何同步上游服务的分支1、fork你本地项目把别人的项目克隆下来,相当于在原项目的主项目下建立一个分支。即将上游服务拷贝到你的本地服务中登录Gitlab->点击2、关联远程库首先将你的本地项目gitclone到本地;输入以下命令gitremoteaddupstream上游仓库名称.git......
  • 从头开始:将新项目上传至Git仓库的简易指南
    无论您是一个经验丰富的开发者还是一个刚刚起步的新手,使用Git来管理您的项目是一个明智的选择。Git是一个强大的版本控制系统,它可以帮助您跟踪项目的变化、合并代码以及与团队成员协作。在本文中,我们将为您提供一步步的指南,教您如何将一个现有的项目上传至仓库。步骤1:创建远程仓库......
  • 深入了解Git:介绍及常用命令指南
    当今软件开发领域中,版本控制是一个至关重要的概念,而Git作为最流行的分布式版本控制系统,发挥着不可替代的作用。本文将介绍Git的基本概念以及常用命令,帮助你更好地理解和使用这一强大的工具。Git简介Git是一种分布式版本管理系统(版本管理就是管理更新的历史记录。它为我们提供了一些......
  • 将git远程代码拉取到本地
    1.打开命令行终端(如Windows中的命令提示符或macOS/Linux中的终端);2.切换到您想要保存代码的本地目录,在命令行中输入:```cd/path/to/your/local/folder```其中`/path/to/your/local/folder`是您想要保存代码的本地文件夹路径。3.输入以下命令来从Git上的......
  • gitblit 不使用远程头像的方法
    gitblit安装非常简单,使用也很方便,由于我初次使用,遇到一个小问题,头像加载不出来,很影响系统的速度,网上找了很久,终于找到了解决办法。1、仓库分组:创建仓库设定名称时录入:groupName/yourRepo即可,groupName为你的分组名称2、默认gitblit用的web头像(地址被封无法访问,这种地址:https://......
  • git-cz 代码提交统一规范配置
    主要插件commitizen:代码提交辅助工具commitlint:代码校验工具husky:githook插件lint-staged:前端文件过滤工具,只检测暂存区代码cz-customizable:自定义提交配置安装步骤1.环境准备git版本,笔者使用gitforwin2.27.0相关钩子无发现问题,也建议>=2.27.0版本,低版......