Post

Git Error

Failed to connect to 127.0.0.1 port 1080: Connection refused

1
2
- 尝试了各种办法都没有解决,一直报这个端口代理的问题,看到网上有一个解决办法
- 我个人是方法一解决了

方法一

  • 第一步 (查询是否使用了代理)
    git config –global http.proxy
  • 第二步(取消代理)
    git config –global –unset http.proxy

方法二

  • 第一步
    在终端输入 defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder 这行命令可以显示电脑的隐形文件
  • 第二步
    在 Finder 里面个人账号的文件夹里找到 gitconfig 这个隐藏文件,右击打开,然后把里面的代理 proxy 整行删掉
  • 第三步
    回到终端,再次执行 pod setup,这个时候你就会神奇的发现,问题解决了,希望对同样有这种问题的人有所帮助

出现目录一直是跳过

  • git config –global –get core.excludesFile
  • 修改即可 /Users/cc/.gitignore_global

推送失败(为重新拉去)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
To http://192.168.1.18:3001/smtface/distinguish_server.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'http://192.168.1.18:3001/smtface/distinguish_server.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

访问http://192.168.1.18:3001/smtface/distinguish_server.git
啊![拒绝]主->主(首先获取)
错误:无法将某些引用推送到“http://192.168.1.18:3001/smtface/distinguish_server.git”
提示:更新被拒绝,因为远程包含您所做的工作
注意:本地没有。这通常是由另一个存储库推送引起的
提示:到同一个 ref。您可能希望首先集成远程更改
提示:(例如,git pull…’)然后再推。
提示:有关详细信息,请参阅“git push--help”中的“关于快速转发的说明”。
  • 推送失败是代码没有拉去最新的 更远程仓库不一致
    最保险的是把你写的代码备份一份
    • 方法 1
      • 先拉去远程仓库最新代码
      • 把备份的代码覆盖再执行提交的所有操作
    • 方法 2 (觉得没有修改什么代码,建议使用)
      • 强制推送到某个分支
      • pit push -u origin master -f
    • 方法 3 (不建议)
      • 创建一个分支
      • 推送到型创建的分支
      • 仓库管理员解决代码冲突问题
      • 你再次拉取代码

推送失败(去历史提交记录)

1. 创建全新的孤立分支 latest_branch

git checkout –orphan latest_branch

2. 暂存所有文件

git add -A

3. 提交所有文件的修改到 latest_branch

git commit -am “del all history”

4. 删除原来的 master 分支

git branch -D master

5. 修改 latest_branch 分支名为 master

git branch -m master

6. 强制更新远程服务器的 master 分支, 至此清空 git 所有历史

git push -f origin master

遇到的问题如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
remote: Gogs: Branch 'master' is protected from force push
To http://192.168.1.18:3001/smtface/api_server.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://192.168.1.18:3001/smtface/api_server.git'

遥控器:护目镜:分支“主”受力推送保护
发送至http://192.168.1.18:3001/smtface/api_server.git
啊![远程拒绝]主->主(预接收挂钩被拒绝)
错误:无法将某些引用推送到“http://192.168.1.18:3001/smtface/api_server.git”

直接复制
git checkout --orphan latest_branch
git add -A
git commit -am "del all history"
git branch -D master
git branch -m master
git push -f origin master

Git 储存损坏

git 提交出现故障

  • git commit
  • git fsck –full
  • git log –oneline –decorate –all head -n 8
  • rm -f .git/objects/43/46883490a0990e68db0187241abc1642765a73

Error 添加

git submodule add root@git.lichaocheng.top:Cc360428/kratos_demo_api.git api

1
'api' already exists in the index

git rm -r –cached api

git submodule add –force https://git.huoys.com/im/im_square_api.git api

git submodule sync

git restore -s HEAD .gitmodules

git submodoule update

This post is licensed under CC BY 4.0 by the author.