gpt4 book ai didi

git - 如果我们在服务器上删除了一个分支,是否可以在我们的本地副本中自动删除它?

转载 作者:太空狗 更新时间:2023-10-29 13:26:40 24 4
gpt4 key购买 nike

通常,当我在 github 上发送 Pull Requests 时,我会创建一个分支,进行更改,然后要求他们将该分支 merge 到他们的 repo 中。

完成后,我会在 Github 上删除分支(但 github 只是 stash 它)。然后我永久删除 Github 站点上的分支。

既然远程分支已经不存在了,我如何才能将我的本地仓库与远程分支同步?我已尝试获取和 pull ,但这并没有删除我本地存储库中的分支。

我是否必须从我的存储库中手动删除它们,或者有什么方法可以同步它们吗?

最佳答案

你可以试试:

git remote prune origin

(假设远程“来源”引用了您的 GitHub 存储库)

这在“cleaning up old remote git branches”中有解释(git branch -d localbranch)

我不知道有哪个本地 git 命令可以同时执行这两项操作。
只有像“git_remote_branch”这样的脚本会同时删除 GitHub 和本地的分支

删除(别名:destroy、kill、remove、rm)

Delete the remote branch then delete the local branch.
The local branch is not deleted if there are pending changes.

$ grb delete branch_name [origin_server]

关于git - 如果我们在服务器上删除了一个分支,是否可以在我们的本地副本中自动删除它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16098537/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com