Skip to content

Zeroplex 生活隨筆

軟體開發、伺服器和生活瑣事

小 縮小字型大小。 中 重設字型大小。 大 放大字型大小。

整理 git local / remote branch

Posted on 2015 年 4 月 25 日2021 年 3 月 12 日 By 日落 在〈整理 git local / remote branch〉中尚無留言

先列出所有的 branch:

$ git branch -a
* api
  cleanCode
  dev
  master
  remotes/github/api
  remotes/github/dev
  remotes/github/master
  remotes/github/pub/anime
  remotes/github/pub/dev
  remotes/github/pub/lock

已知其中 “pub/*” 開頭的 branch 其實已經都不存在了,這時候如果刪除 remote branch 會出現錯誤訊息:

$ git push github :pub/lock
error: unable to delete 'pub/lock': remote ref does not exist
error: failed to push some refs to 'git@github.com:johnroyer/aniTrace-fuel.git'

表示 local container 已經和 remote 資料有差異了。

這時候可以用 prune 指令,讓 git 同步 local 和 remote 的資料:

git remote prune github

執行後,若 remote 已經刪除的 branch,也不會在 git branch -a 時顯示了。

Tags:Git

文章導覽

Previous Post: Case-insensitive in HFS+
Next Post: Git 2.4.0 Released

發佈留言 取消回覆

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *


其他

關於我  (About me)

小額贊助

  文章 RSS Feed

  留言 RSS Feed

Apache AWS Bash C/C++ Docker FreeBSD GCP Git Google Java JavaScript Laravel Linux Microsoft MSSQL MySQL Nginx PHP PHPUnit PostgreSQL Python Qt Ubuntu Unix Vim Web Windows WordPress XD 作業系統 分享 好站推薦 專題 攝影 新奇搞笑 新聞 旅遊 生活雜記 程式設計 網路架站 網頁設計 資訊學習 資訊安全 遊戲 音樂


創用 CC 授權條款
本著作係採用創用 CC 姓名標示-相同方式分享 4.0 國際 授權條款授權.