重命名远程分支 [英] Rename remote branch
问题描述
我创建了一个本地分支X,它在某些时候被推送到远程服务器(原始地址)
git push origin X
我意识到有一个名为X的分支并希望它被称为Y
问题是我已经将分支推送到了存储库。
将它从服务器中删除并将其按照像这样的新名称推送是安全的吗?
push来源:X
//'clone'在本地以新名称命名的分支(X - > Y)
推送来源Y
会发生什么已经从服务器获取的人员。假设他们已经有
在本地基于旧的X名称 BUT 创建了一个分支,他们没有在本地进行任何更改,或将它们推送到旧的X分支的服务器。
其他人将保留一个指向分支X的指针(如 origin / X
)直到他们运行 git remote prune origin
。它被留作 stale分支
当获取/拉动时,它们将获得第二个指向新创建的分支Y(如<$ c
$ b
分支和合并不受此影响。
所以,只要所有提交都可以从你的分支到达,重命名就可以了。
I have created a local branch X that at some point I pushed to remote server (origin)
git push origin X
I realized it's a bad idea to have branch named X and want it to be called Y The problem is that I've already pushed the branch to the repository.
Is it safe to delete it from the server and push it under a new name like this ?
push origin :X
// 'clone ' the branch under a new name locally ( X-> Y)
push origin Y
What will happen to the people that already fetched from the server. Say that they already made a branch locally based on the old X name BUT they did not make any changes locally or pushed them to the server for the old X branch.
other people will keep a pointer to branch X (as origin/X
) in their repository until they run git remote prune origin
. it's left as a stale branch
when fetching/pulling they will get a second point to (newly created) branch Y (as origin/Y
)
branching and merging is not affected by this.
so, as long as all commits are still reachable from your branch, renaming is fine.
这篇关于重命名远程分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!