linux - 如何通过 1 步将本地分支删除传播到远程 - git, github

标签 linux git github

当我想在 git 上本地删除一个分支并将其传播到 GitHub 存储库时,我使用这个两步法:

~$ git branch -d [branch_name]
~$ git push origin :[branch_name]

是否有任何命令可以在本地删除分支并自动将此修改传播到 GitHub 上的远程仓库?

最佳答案

git config alias.yourcommandnamehere \
        '! f() { git branch -d $1; git push origin :$1; }; f'

git yourcommandnamehere branch_name

请注意,git 不会为内置函数提供别名。 Many of them do have config items提供默认值。

关于linux - 如何通过 1 步将本地分支删除传播到远程 - git, github,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23797257/

相关文章:

linux - 有关如何为 python 设置 vim 的文档?

git - 如何回滚 Git repo 到第一次提交并删除所有历史记录

git - 通过 pull 请求撤消 merge ?

git - GitHub 存储库中的文件数

c++ - 我想使用 GitHub 和 (a) IDE 在 Mac 和 Linux 两个平台上用 C++ 编写程序

linux - 如何删除 ELF 文件中的节头表?

linux - 使用脚本运行有限数量的并行程序

linux - 用于 SSH 到多个服务器的 Bash 脚本,如果登录失败则继续

git - 如何更改 Shell 脚本中的目录?

git - 使用 git 贡献