GIT 删除远程remote branch方法

本文介绍了如何使用Git进行分支管理,包括查询、删除本地及远程分支的方法,并提供了实用的命令示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GIT 越用越好用呢。

如何查询branch呢

git-show-branch - Show branches and their commits

参考博文:

https://git-scm.com/docs/git-show-branch

如何删除错误建立的branch呢

步骤一、首先删除本地branch的方法

git branch -D bugfix

 -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

Shortcut for --delete --force.

-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. In combination with -d (or --delete), allow deleting the branch irrespective of its merged status. In combination with -m (or --move), allow renaming the branch even if the new branch name already exists.

步骤二、删除远程branch

git push origin --delete <branchName>

 步骤三、本地不要再追踪远程中已经没有用的了

  Deleting a local remote-tracking branch:

git fetch --all --prune

After deleting the local branch with git branch -d and deleting the remote branch withgit push origin --delete other machines may still have "obsolete tracking branches" (to see them dogit branch -a).

"git fetch" learned --all and --multipleoptions, to run fetch from many repositories, and --prune option to remove remote tracking branches that went stale. These make "git remote update" and "git remote prune" less necessary (there is no plan to remove "remote update" nor "remote prune", though).

转载于:https://my.oschina.net/u/2308739/blog/693622

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值