問題描述
昨天,以及今天(2014-11-29),使用 TortoiseGit 時碰到了一個詭異的問題. 卸載,清理注冊表,重裝,重啟,各種折騰以后,還是不能解決. 但是23.45分一過,突然靈光一閃,解決了.
問題是這樣的. 使用命令行的?git push,?git fetch,?git pull?什么的都沒問題. 但是使用 TortoiseGit 執(zhí)行拉取(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?未能順利結(jié)束?(退出碼?1)?(3510?ms?@?2014/11/29?23:51:56)??
死活各種折騰,根據(jù)提示,說: 你的配置指定了去合并(merge)遠端的'master',但沒有獲取(fetch)到這個引用(ref).
?
然后各種測試,各種折騰,總算發(fā)現(xiàn)了一點規(guī)律. 如果 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?這個文件,注意此文件沒有后綴.
- 還可以在項目根目錄下點擊鼠標(biāo)右鍵, 選擇 TortoiseGit --> Settings(設(shè)置 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)??
一對比就發(fā)現(xiàn)第一行 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?? ?
需要注意的是,因為遠端有多個分支,所以這個配置文件里,相應(yīng)的就多了一個小節(jié)?[branch "master"],而 這個小節(jié)下面的 remote = origion, 現(xiàn)在加上 master 變?yōu)?
?
[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 當(dāng)前版本的一個 BUG]
總結(jié)
有些日子,不適合寫代碼,也不適合調(diào)程序, 但適合填坑, 也許坑填的多了,時間一轉(zhuǎn),問題就解決了。
?
相關(guān)文章
?
目錄安裝及配置Git安裝及配置TortoiseGitGit與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
?
轉(zhuǎn)載于:https://www.cnblogs.com/softidea/p/4881325.html
總結(jié)
以上是生活随笔為你收集整理的解决 TortoiseGit 诡异的 Bad file number 问题(转)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。