美文网首页
git 使用之 sourcetree 报过的错

git 使用之 sourcetree 报过的错

作者: AlessiaLi | 来源:发表于2016-12-24 15:17 被阅读1749次

    #1

    错误提示:

    remote: aborting due to possible repository corruption on the remote side.
    fatal: protocol error: bad pack header
    

    截图:

    git error #1

    备注:使用 git 图形化工具 - sourcetree

    导致错误的原因:

    远程项目文件体积过大!由于人为的失误,使得项目文件增至 400 多兆,因此我无论是拉取还是克隆都显示了如上的错误提示。

    解决方案:

    第一种:
    参考:Git indexing fails due to bad pack header

    Resolution
    Log in to the server as the SSH user used to connect to the repo and run the commands below(在远程服务器上运行如下设置):

    git config --global pack.windowMemory "100m"
    git config --global pack.SizeLimit "100m"
    git config --global pack.threads "1"
    

    第二种:
    直接删了该因失误而体积过大的 repository,新建一个正常的,可马上恢复使用。(我们的实际解决方式,简单粗暴)

    #2

    错误提示:

    error: src refspec master does not match any.
    error: failed to push some refs to 'https://*****.git'
    

    截图:

    git error #2

    备注:使用 git 命令行 - Git Bash

    导致错误的原因:

    目录中没有文件,空目录是不能提交上去的。
    目录中有文件,但没有提交,无 commit 是没法 push 的。

    解决方案:

    一般 Git 提交的几个步骤如下:

    1. github / bitbucket 上创建项目
    2. 使用 git clone https://github.com/xxxxxxx/xxxxx.git 将项目克隆到本地
    3. 编辑项目
    4. git add . (将改动添加到暂存区)
    5. git commit -m "提交说明"
    6. git push origin master 将本地更改推送到远程 master 分支。

    这样你就完成了向远程仓库的推送。

    在我的操作过程中,我是将本地项目推送到远程仓库,步骤如下:

    1. github / bitbucket 上创建项目
    2. 初始化本地项目:git init
    3. 将本地项目与远程仓库进行连接:git remote add origin https://******.git
    4. git add . (将改动添加到暂存区)
    5. git commit -m "提交说明"
    6. git push -u origin master

    我忘记执行4、5步骤,导致出现上面错误。

    #3

    错误:

    明明对文件进行了修改,但在 sourcetree 中始终不显示未暂存文件。

    导致错误的原因:

    未知。

    解决方案:

    直接使用 git 命令行来提交更新。

    1. 在项目根目录右键,选择 git bash,打开命令行界面。
    2. git add . (将改动添加到暂存区)
    3. git commit -m "提交说明"
    4. git push 将本地更改推送到远程分支。

    To be continued

    相关文章

      网友评论

          本文标题:git 使用之 sourcetree 报过的错

          本文链接:https://www.haomeiwen.com/subject/vmglvttx.html