GIT 刪除遠程remote branch方法

GIT 越用越好用呢。

如何查詢branch呢git

git-show-branch - Show branches and their commits

參考博文:express

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

如何刪除錯誤創建的branch呢fetch

步驟1、首先刪除本地branch的方法

git branch -D bugfix

 -d

--deletespa

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.code

-Dip

Shortcut for --delete --force.rem

-lget

--create-reflogit

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.

步驟2、刪除遠程branch

git push origin --delete <branchName>

 步驟3、本地不要再追蹤遠程中已經沒有用的了

  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).

相關文章
相關標籤/搜索