Git bad signature

$ git add .
error: bad signature 0x00000000
fatal: index file corrupt

由于index file索引文件在Git中指的是.git/index这个文件,索引文件保存的是暂存区信息,可通过git ls-files --stage查看暂存区内容。

$ git ls-files --stage
error: bad signature 0x00000000
fatal: index file corrupt

出现index file corrupt说明暂存区索引文件已经损坏,删除后可重新生成。

删除索引文件

$ rm -f .git/index

重建索引文件

$ git read-tree
warning: read-tree: emptying the index with no arguments is deprecated; use --empty

若使用git read-tree失败则采用

$ git reset
Unstaged changes after reset:
M       application/admin/controller/Gain.php
M       application/admin/view/gain/create.html
M       application/index/controller/Test.php
M       application/index/controller/Withdraw.php

It took 9.47 seconds to enumerate unstaged changes after reset.  You can
use '--quiet' to avoid this.  Set the config setting reset.quiet to true
to make this the default.

$ git pull
warning: Pulling without specifying how to reconcile divergent branches is
discouraged. You can squelch this message by running one of the following
commands sometime before your next pull:

  git config pull.rebase false  # merge (the default strategy)
  git config pull.rebase true   # rebase
  git config pull.ff only       # fast-forward only

You can replace "git config" with "git config --global" to set a default
preference for all repositories. You can also pass --rebase, --no-rebase,
or --ff-only on the command line to override the configured default per
invocation.

警告:不建议在没有为偏离分支指定合并策略时执行pull操作。
您可以在执行下一次pull操作之前执行下面一条命令来抑制本消息:

git config pull.rebase false # 合并(缺省策略)
git config pull.rebase true # 变基
git config pull.ff only # 仅快进

您可以将 "git config" 替换为 "git config --global" 以便为所有仓库设置
缺省的配置项。您也可以在每次执行 pull 命令时添加 --rebase、--no-rebase,
或者 --ff-only 参数覆盖缺省设置。

上诉问题也就是典型的git pull冲突,即本地存在commit但尚未提交,origin也具有新的commit,同时发生冲突。解决方案

$ git config --global pull.rebase false
$ git config --global -l

执行git pull命令等价于先执行git fetch再执行git merge FETCH_HEAD将远程仓库对应分支的最新提交合并到当前本地分支中。git fetch会查询git remote中所有的远程仓库所包含分支的最新提交,并将其记录到.git/FETCH_HEAD文件中。.git/FETCH_HEAD是一个版本链接,指向目前已经从远程仓库获取下来的所有分支的最新提交。

git pull选项

  • git pull无选项时表示先尝试快进合并,若失败则进行正常合并生成一个新的提交。
  • git pull --ff-only表示只尝试快进合并,若失败则终止当前合并操作。
  • git pull --no-ff表示禁止快进合并,即不管能不能快进合并,最后都会进行正常合并生成一个新的提交。
  • git pull --rebase表示先尝试快进合并,若失败则进行变基合并。

设置项目账户与邮箱

$ git config user.name "admin"
$ git config user.email "admin@hotmail.com"
$ git config -l

记住密码,默认15分钟。

$ git config --global credential.helper cache

记住密码,自定义时间,比如1小时后失效。

$ git config --global credential.helper 'cache --timeout=3600'

长期存储密码

$ git config --global credential.helper store
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值