git踩坑

git仓库大文件push失败报413 Request Entity Too Large 问题解决办法

使用https方式拉取的git仓库,在push文件时报错Gitlab error push files 413 Request Entity Too Large

尝试了如下

  1. 增大https方式的post缓存 (不成功)
git config http.postBuffer 524288000

2.修改本地仓库的https方式为ssh (成功)

git remote set-url origin ssh地址

git pull遇到错误:error: Your local changes to the following files would be overwritten by merge

原因:本地项目有修改,不能更新

方法1: 如果你想保留刚才本地修改的代码,并把git服务器上的代码pull到本地(本地刚才修改的代码将会被暂时封存起来)

git stash 

git pull origin master

git stash pop

服务器上的代码更新到了本地,而且你本地修改的代码也没有被覆盖,之后使用add,commit,push 命令即可更新本地代码到服务器了。

方法2: 如果你想完全地覆盖本地的代码,只保留服务器端代码,则直接回退到上一个版本,再进行pull

  1. git reset –soft [提交id]

    只移动 HEAD 到指定的 commit,但保留原先暂存区和工作目录的内容,同时会将指定 commit 之后提交的内容设置到暂存区中

  2. git reset –mixed [提交id]

    移动 HEAD 到指定的 commit,同时重置暂存区为指定 commit 的状态(将内容从 HEAD 复制到暂存区中),但保留原先的工作目录,同时将添加暂存区的修改撤销到工作目录中。该选项为默认选项,可以省略

  3. git reset –hard [提交id]

    移动 HEAD,同时重置暂存区和工作目录到指定 commit。也即是将三个树都重置为指定的 commit。

Git会有三个区域:

  • Working Tree 当前的工作区域

  • Index/Stage 暂存区域,和git stash命令暂存的地方不一样。使用git add xx,就可以将xx添加近Stage里面

  • Repository 提交的历史,即使用git commit提交后的结果

    image-20220411075350414

git reset --hard [提交id]

git pull origin master

方法3:合并代码

git add .
git commit -m "xxx"
git pull
git push

命令Hexo d上传GitHub超时报错

atal: unable to access 'https://github.com/.......': OpenSSL SSL_read: Connection was reset, errno 10054

产生原因:一般是这是因为服务器的SSL证书没有经过第三方机构的签署,所以报错

参考网上解决办法:解除ssl验证后 (无效果)

git config --global http.sslVerify "false"

或出现错误

fatal: unable to access 'https://github.com/.../.git': Could not resolve host: github.com

参考网上解决办法:解除代理 (无效果)

git config --global --unset http.proxy 
git config --global --unset https.proxy

或出现错误

fatal: unable to access 'https://github.com/Chankeitin/Chankeitin.github.io.git/': Failed to connect to github.com port 443: Timed out

或出现错误

fatal: unable to access 'https://github.com/Chankeitin/Chankeitin.github.io.git/': Empty reply from server
FATAL {
......
}
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html

最后统一解决:

重复运行命令,直到push成功