git推送重命名分支

git推送重命名分支,git,github,repository,rename,Git,Github,Repository,Rename,我正在尝试使用重命名项目的一个分支 git branch -m old_branch_name new_brach_name 重命名本地分支,该操作正常,本地分支已重命名。但是在从远程(github上或git shell中)删除旧的分支名称并使用 git push origin new_branch_name 我得到这个输出 Counting objects: 92, done. Delta compression using up to 4 threads. Compressing obj

我正在尝试使用重命名项目的一个分支

git branch -m old_branch_name new_brach_name
重命名本地分支,该操作正常,本地分支已重命名。但是在从远程(github上或git shell中)删除旧的分支名称并使用

git push origin new_branch_name
我得到这个输出

Counting objects: 92, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (60/60), done.
Writing objects: 100% (92/92), 488.48 KiB | 0 bytes/s, done.
Total 92 (delta 3), reused 0 (delta 0)
To https://github.com/<username>/<repo_name>.git
 * [new branch]      new_branch_name -> old_branch_name
计数对象:92,完成。
增量压缩最多使用4个线程。
压缩对象:100%(60/60),完成。
写入对象:100%(92/92),488.48千字节/秒,完成。
总计92(增量3),重复使用0(增量0)
到https://github.com//.git
*[新分支机构]新分支机构名称->旧分支机构名称
旧的分支名称仍然显示在远程和github上


有什么好处?我在这里搜索了很多次,我找不到其他人重命名分支并让git在将其推到远程时重新命名它的实例。

即使您将
old_branch_name
的本地名称更改为
new_branch_name
,此本地分支仍在GitHub上跟踪同一远程分支(或存储库所在的任何位置)。为了告诉Git您希望此本地分支跟踪不同的远程分支,您需要明确告诉它新的本地分支也有一个新的上游位置:

git checkout new_branch_name
git push --set-upstream origin new_branch_name

在上面的
git push
命令中,
new\u branch\u name
是您希望本地分支跟踪的远程分支的名称。

即使您将
old\u branch\u name
的本地名称更改为
new\u branch\u name

您仍然需要推送
旧分支机构名称
删除(推送新名称后):

git推送原点:

这与此相同。输出为
*[new branch]new\u branch->old\u branch-new\u branch-set,用于从原点跟踪远程分支old\u branch。
git push origin :<old_name>