日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

解决 TortoiseGit 诡异的 Bad file number 问题(转)

發布時間:2025/3/20 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 解决 TortoiseGit 诡异的 Bad file number 问题(转) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

問題描述

昨天,以及今天(2014-11-29),使用 TortoiseGit 時碰到了一個詭異的問題. 卸載,清理注冊表,重裝,重啟,各種折騰以后,還是不能解決. 但是23.45分一過,突然靈光一閃,解決了.

問題是這樣的. 使用命令行的?git push,?git fetch,?git pull?什么的都沒問題. 但是使用 TortoiseGit 執行拉取(pull ...) 命令時, 就給報錯, 報錯信息如下:

?

[plain]?view plaincopy
  • git.exe?pull?-v?--no-rebase?--progress?"origin"??
  • ??
  • /libexec/git-core/git-sh-setup:?line?83:?/bin/sed:?Bad?file?number??
  • From?https://github.com/cncounter/translation??
  • =?[up?to?date]??????master?????->?origin/master??
  • D:\Develop\Git/libexec/git-core\git-pull:?line?268:?/bin/tr:?Bad?file?number??
  • Your?configuration?specifies?to?merge?with?the?ref?'master'??
  • from?the?remote,?but?no?such?ref?was?fetched.??
  • ??
  • git?未能順利結束?(退出碼?1)?(3510?ms?@?2014/11/29?23:51:56)??

  • 死活各種折騰,根據提示,說: 你的配置指定了去合并(merge)遠端的'master',但沒有獲取(fetch)到這個引用(ref).

    ?

    然后各種測試,各種折騰,總算發現了一點規律. 如果 GitHub 在線倉庫只有一個分支, 也就是 master 時, Pull 拉取就不報錯, 如果在線的遠端倉庫有多個分支,如?master?加上?gh-pages?時,一拉取就報這個錯. 但使用 git 命令行就沒有這個問題. 那么問題來了, 肯定是 TortoiseGit 的哪里配置不對.

    想去想來,突然想在 局部倉庫的配置文件中修改下, 先看看會報錯的這種配置:

    ?

    [plain]?view plaincopy
  • [core]??
  • ????repositoryformatversion?=?0??
  • ????filemode?=?false??
  • ????bare?=?false??
  • ????logallrefupdates?=?true??
  • ????symlinks?=?false??
  • ????ignorecase?=?true??
  • ????hideDotFiles?=?dotGitOnly??
  • [remote?"origin"]??
  • ????url?=?https://github.com/cncounter/translation.git??
  • ????fetch?=?+refs/heads/*:refs/remotes/origin/*??
  • [branch?"master"]??
  • ????remote?=?origin??
  • ????merge?=?refs/heads/master??
  • [remote]??
  • ????pushdefault?=?origin??
  • [credential]??
  • ????helper?=?store??
  • ?

    ?

    查看方法:

    • 打開Git項目根目錄, 找到 .git 文件夾,進去里面編輯?config?這個文件,注意此文件沒有后綴.
    • 還可以在項目根目錄下點擊鼠標右鍵, 選擇 TortoiseGit --> Settings(設置 S), 然后選擇左邊的 Git --> 右邊的?編輯本地.git/config?按鈕,即可打開這個文件,如下圖所示:

    那么,看看一個正常的pull拉取操作會有哪些日志輸出呢?

    ?

    [plain]?view plaincopy
  • git.exe?pull?-v?--no-rebase?--progress?"origin"?master??
  • ??
  • From?https://github.com/renfufei/asynquence??
  • *?branch????????????master?????->?FETCH_HEAD??
  • =?[up?to?date]??????master?????->?origin/master??
  • Already?up-to-date.??
  • ??
  • 成功?(5959?ms?@?2014/11/30?0:11:27)??

  • 一對比就發現第一行 git pull ..... 最后面少了一個 master. 于是想著在 config 文件里面加上這個 master 看看行不行.

    ?

    修改后的配置如下:

    ?

    [plain]?view plaincopy
  • [core]??
  • ????repositoryformatversion?=?0??
  • ????filemode?=?false??
  • ????bare?=?false??
  • ????logallrefupdates?=?true??
  • ????symlinks?=?false??
  • ????ignorecase?=?true??
  • ????hideDotFiles?=?dotGitOnly??
  • [remote?"origin"]??
  • ????url?=?https://github.com/cncounter/translation.git??
  • ????fetch?=?+refs/heads/*:refs/remotes/origin/*??
  • [branch?"master"]??
  • ????remote?=?origin?master??
  • ????merge?=?refs/heads/master??
  • [remote]??
  • ????pushdefault?=?origin??
  • [credential]??
  • ????helper?=?store??
  • ?

    需要注意的是,因為遠端有多個分支,所以這個配置文件里,相應的就多了一個小節?[branch "master"],而 這個小節下面的 remote = origion, 現在加上 master 變為:

    ?

    [plain]?view plaincopy
  • [branch?"master"]??
  • ????remote?=?origin?master??
  • ????merge?=?refs/heads/master???

  • 如下圖所示:

    ?

    保存,再次測試,OK,可以正常拉取:

    ?

    [plain]?view plaincopy
  • git.exe?pull?-v?--no-rebase?--progress?"origin"?master??
  • ??
  • From?https://github.com/cncounter/translation??
  • *?branch????????????master?????->?FETCH_HEAD??
  • =?[up?to?date]??????master?????->?origin/master??
  • Already?up-to-date.??
  • ??
  • 成功?(2246?ms?@?2014/11/30?0:19:25)??

  • 注意看到, 在第一行 git.exe pull .... 最后面多出了一個 master:

    ?

    好了,問題完美解決.[這可能是 TortoiseGit 當前版本的一個 BUG]

    總結

    有些日子,不適合寫代碼,也不適合調程序, 但適合填坑, 也許坑填的多了,時間一轉,問題就解決了。

    ?

    相關文章

    ?

  • 目錄
  • 安裝及配置Git
  • 安裝及配置TortoiseGit
  • Git與TortoiseGit基本操作
  • MarkDown示例
  • 解決 TortoiseGit 詭異的 Bad file number 問題
  • 加入QQ群GitHub家園: 225932282
  • ?

    日期: 2014-11-29
    作者: 鐵錨:?http://blog.csdn.net/renfufei

    ?

    GitHub版本:?https://github.com/cncounter/translation/blob/master/tiemao_2014/GitHelp/05_BadFileNumber.md

    ?

    轉載于:https://www.cnblogs.com/softidea/p/4881325.html

    總結

    以上是生活随笔為你收集整理的解决 TortoiseGit 诡异的 Bad file number 问题(转)的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。