精华内容
下载资源
问答
  • git修改本地分支名称

    千次阅读 2019-06-27 14:09:03
    在项目目录下右键 Git Bash Here 输入如下命令: (将testLocalBranch修改为test) $ git branch -m testLocalBranch test 效果如下: 修改后,查询本地分支

    在项目目录下右键 Git Bash Here
    在这里插入图片描述
    输入如下命令: (将testLocalBranch修改为test)

    $ git branch -m testLocalBranch test
    

    效果如下:
    在这里插入图片描述
    修改后,查询本地分支
    在这里插入图片描述

    展开全文
  • http://www.yiibai.com/git/git_managing_branches.html ...那么可通过使用-m选项后跟旧的分支名称和新的分支名称来更改/重新命名分支名称。 $ git branch * master new_branch Administrat...

     

    http://www.yiibai.com/git/git_managing_branches.html

    重命名分支

    假设需要在项目中添加对宽字符的支持。并且已经创建了一个新的分支,但分支名称需要重新命名。那么可通过使用-m选项后跟旧的分支名称和新的分支名称来更改/重新命名分支名称。

    $ git branch
    * master
      new_branch
    
    Administrator@MY-PC /D/worksp/sample (master)
    $ git branch -m new_branch wchar_support

    现在,使用git branch命令显示新的分支名称。

    $ git branch
    * master
      wchar_support






     

    git branch用法总结

    标签: branchgit

    git branch
       
       git branch 不带参数:列出本地已经存在的分支,并且在当前分支的前面加“*”号标记,例如:
       #git branch
    * master
       newbranch

       git branch -r 列出远程分支,例如:
       #git branch -r
       m/master -> origin_apps/m1_2.3.4
       origin_apps/hardware/test
       origin_apps/m1
       origin_apps/m1_2.3.4
       origin_apps/master

       git branch -a 列出本地分支和远程分支,例如:
       #git branch -a
       * master
       newbranch
       remotes/m/master -> origin_apps/m1_2.3.4
       remotes/origin_apps/hardware/test
       remotes/origin_apps/m1
       remotes/origin_apps/m1_2.3.4
       remotes/origin_apps/master

       git branch 创建一个新的本地分支,需要注意,此处只是创建分支,不进行分支切换,例如:
       #git branch newbranch2
       #git branch
       * master
       newbranch
       newbranch2
       当前的分支依然是master,不进行切换。

       git branch -m | -M oldbranch newbranch 重命名分支,如果newbranch名字分支已经存在,则需要使用-M强制重命名,否则,使用-m进行重命名。

       git branch -d | -D branchname 删除branchname分支

       git branch -d -r branchname 删除远程branchname分支


    例子:
    git help branch中的一个例子:
       $ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
       $ cd my2.6
       $ git branch my2.6.14 v2.6.14   
       $ git checkout my2.6.14      
       第三行符合git branch <branchname> [<start-point>]的格式,即以v2.6.14为start-point,创建新的本地分支branchname。






    SYNOPSIS

    git branch [--color[=<when>] | --no-color] [-r | -a]
            [--list] [-v [--abbrev=<length> | --no-abbrev]]
            [--column[=<options>] | --no-column]
            [(--merged | --no-merged | --contains) [<commit>]] [<pattern>…]
    git branch [--set-upstream | --track | --no-track] [-l] [-f] <branchname> [<start-point>]
    git branch (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]
    git branch --unset-upstream [<branchname>]
    git branch (-m | -M) [<oldbranch>] <newbranch>
    git branch (-d | -D) [-r] <branchname>…
    git branch --edit-description [<branchname>]
     

    DESCRIPTION

    If --list is given, or if there are no non-option arguments, existing branches are listed; the current branch will be highlighted with an asterisk. Option -r causes the remote-tracking branches to be listed, and option -a shows both local and remote branches. If a <pattern> is given, it is used as a shell wildcard to restrict the output to matching branches. If multiple patterns are given, a branch is shown if it matches any of the patterns. Note that when providing a <pattern>, you must use --list; otherwise the command is interpreted as branch creation.

    With --contains, shows only the branches that contain the named commit (in other words, the branches whose tip commits are descendants of the named commit). With --merged, only branches merged into the named commit (i.e. the branches whose tip commits are reachable from the named commit) will be listed. With --no-merged only branches not merged into the named commit will be listed. If the <commit> argument is missing it defaults to HEAD (i.e. the tip of the current branch).

    The command’s second form creates a new branch head named <branchname> which points to the current HEAD, or <start-point> if given.

    Note that this will create the new branch, but it will not switch the working tree to it; use "git checkout <newbranch>" to switch to the new branch.

    When a local branch is started off a remote-tracking branch, Git sets up the branch (specifically the branch.<name>.remote and branch.<name>.merge configuration entries) so that git pull will appropriately merge from the remote-tracking branch. This behavior may be changed via the global branch.autosetupmerge configuration flag. That setting can be overridden by using the --track and --no-track options, and changed later using git branch --set-upstream-to.

    With a -m or -M option, <oldbranch> will be renamed to <newbranch>. If <oldbranch> had a corresponding reflog, it is renamed to match <newbranch>, and a reflog entry is created to remember the branch renaming. If <newbranch> exists, -M must be used to force the rename to happen.

    With a -d or -D option, <branchname> will be deleted. You may specify more than one branch for deletion. If the branch currently has a reflog then the reflog will also be deleted.

    Use -r together with -d to delete remote-tracking branches. Note, that it only makes sense to delete remote-tracking branches if they no longer exist in the remote repository or if git fetch was configured not to fetch them again. See also the prune subcommand of git-remote(1) for a way to clean up all obsolete remote-tracking branches.

    OPTIONS

    -d
    --delete

    Delete a branch. The branch must be fully merged in its upstream branch, or in HEAD if no upstream was set with --track or --set-upstream.

    -D

    Delete a branch irrespective of its merged status.

    -l
    --create-reflog

    Create the branch’s reflog. This activates recording of all changes made to the branch ref, enabling use of date based sha1 expressions such as "<branchname>@{yesterday}". Note that in non-bare repositories, reflogs are usually enabled by default by the core.logallrefupdates config option.

    -f
    --force

    Reset <branchname> to <startpoint> if <branchname> exists already. Without -f git branch refuses to change an existing branch.

    -m
    --move

    Move/rename a branch and the corresponding reflog.

     

    转载于:https://www.cnblogs.com/ydxblog/p/7987694.html

    展开全文
  • git 修改本地分支名称和远程分支名称1、修改本地分支名称2、删除远程分支3、将本地分支与远程新分支关联起来 因为分支名建的时候弄错了,所以我就直接修改了本地的分支名,但是远程的分支名没有修改过来。 我删了...


    因为分支名建的时候弄错了,所以我就直接修改了本地的分支名,但是远程的分支名没有修改过来。
    我删了远程的分支名之后,把修改过后的分支重新推上去,但是远程的分支名还是显示原来的旧分支名,下面的操作可以让你把远程分支名也一起修改了的

    branch-A 为旧分支名称
    branch-B 为新分支名称

    1、修改本地分支名称

    git branch -m branch-A branch-B
    

    2、删除远程分支

    git push origin :branch-A
    

    3、将本地分支与远程新分支关联起来

    git push --set-upstream origin branch-B
    
    展开全文
  • 说明:假如分支名字是...2.修改本地分支名称 git branch -m oldBranchName newBranchName 3.删除对应的远程分支 git push origin --delete oleBranchName 4.推送本地新分支 git push origin newBranchName 5.关联本

    说明:假如分支名字是oldBranchName,要修改成newBranchName,实际操作时候要修改成自己分支的名称。

    1.在本地切换到要改名的分支
    git checkout oldBranchName
    
    2.修改本地分支名称
    git branch -m oldBranchName newBranchName
    
    3.删除对应的远程分支
    git push origin --delete oldBranchName
    
    4.推送本地新分支
    git push origin newBranchName
    
    5.关联本地分支和远程分支
    git branch --set-upstream-to origin/newBranchName
    
    展开全文
  • 平时的项目git管理中,可能会遇到修改git项目分支名称的情况: 第一步:将本地分支改名 git branch –m old_branch new_branch 第二步:将本地分支的远程删除(推送远程分支) git push origin :old_branch 第...
  • git 如何修改本地分支名称与远程分支名称 在工作中经常会遇到需要修改分支名的问题,假设现在的分支名为 20190408_old_branch,然后发现自己的分支名好像写错了,这时候应该如何修改本地分支名称与远程分支名称呢?...
  • git本地分支修改名称

    万次阅读 2018-08-23 10:25:54
    给一个git分支改名的方法很简单 如果对于分支不是当前分支,可以使用下面代码: git branch -m 原分支名 新分支名 如果是当前,那么可以使用加上新名字 git branch -m 原分支名称 ...
  • git修改远程分支名称

    千次阅读 2019-06-27 14:25:02
    修改本地分支名称 提交修改后的本地分支 在项目目录下右键 Git Bash Here 依次执行如下命令: $ git push --delete origin 远程分支名称 $ git branch -m testLocalBranch test $ git push origin test 效果如下: ...
  • git修改本地分支为master

    千次阅读 2019-06-26 16:15:04
    本地有一个git管控的代码,分支名称为:hyd 由于这个代码从我接手后就一直只有我在维护,所以后来为了方便(减少合并代码这操作),我决定把本地分支换成master。 在.git目录中, 1. 删除所有 hyd 文件 2. 把 HEAD...
  • git 修改远程分支名称

    2021-01-29 10:01:23
    首先 git branch -m 旧分支名 新分支名 其次 git push --delete origin 旧分支名 将新分支名推上去 git push origin 新分支名 ...将新本地分支和远程相连 git branch --set-upstream-to origin/新分支名
  • 1、git修改本地和远程分支名称git branch -m old_branch new_branch # Rename branch locally git push origin :old_branch # Delete the old branch git push --set-upstream origin new_branch # Push the new...
  • 注:修改远程分支先拉下来再进行以下步骤 旧分支:oldBranch 新分支:newBranch 步骤: 1、先将本地分支重命名 ...git branch -m oldBranch new...4、把修改后的本地分支与远程分支关联 git branch --set-upstream
  • a、先将本地分支重命名 git branch -m oldBranch newBranch b、删除远程分支(远端无此分支则跳过该步骤) git push --delete origin oldBranch c、将重命名后的分支推到远端 git push origin newBran...
  • git branch -a #查看所有分支...git branch -vv #查看本地分支所关联的远程分支 git branch -m old_branch new_branch # Rename branch locally git push origin :old_branch # Delete the old branch git push --se...

空空如也

空空如也

1 2 3 4 5 ... 16
收藏数 310
精华内容 124
关键字:

git修改本地分支名称