美文网首页
解决git push问题

解决git push问题

作者: xymspace | 来源:发表于2020-05-02 12:46 被阅读0次
  • push代码遇到如下问题:

  • push origin master 没有权限
~:git push origin master

的时候,terminal报错没有权限。

unable to access ' https://git.coding.net/xxxx/xxxx.git/ ': The requested URL returned error: 403

  • 根据git用户名密码缓存原理:
  1. git 去找系统是否缓存了用户的密码有三种策略:去缓存中找,去磁盘中找,去钥匙串中找。

  2. /Users/xxx/.gitconfig 文件中(这个文件如果没设置过git 的全局配置可能会不存在),配置了git 到底选择哪个策略去找用户名和密码。

  3. 通过编辑 .gitconfig 文件,credential.helper = store/cache/osxkeychain 来修改 git 缓存策略。


  • 尝试过的解决方案:

方案一:

修改.git——>config的url
  1. 修改工程的.git 目录下的.config文件(url增加红字内容)
    [remote "origin"]
    url = https://用户名:密码@github.com/用户名/xxxx.git
  2. 命令行:
git push -u origin master
报错处理
错误一:
fatal: refusing to merge unrelated histories

命令行:

#如果是git pull,同理:
~:git pull origin master --allow-unrelated-histories
~:git push -u origin master -f
错误二:
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/XDGitHub/XMPPTool.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

命令行:

~:git push -u origin master -f

方案二:

重新配置本地的git个人信息

第一次git push origin master 时,不提示输入用户名和密码

查看本地的credential:

~:git help -a | grep credential

查看本地git全局配置:

~:git config --list

配置自己的git信息:

#配置git 的缺省编辑器
~:git config --global core.editor emacs

#配置git 的用户名和邮箱
~:git config --global user.name "xxxxxx"
~:git config --global user.email "xxxx@.com"

检查本地config

~:git config credential.helper

如果出现结果:

osxkeychain

需要删除该配置。命令行:

git config --show-origin --get credential.helper
file:/Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig    osxkeychain
~:open /Applications/Xcode.app/Contents/Developer/usr/share/git-core/

打开gitconfig,删除内容:

[credential]   helper = xxx

~:git config credential.helper
# 没有输出结果即删除本地缓存的用户名和密码生效

重新配置:

~:git  config --global  credential.helper  store
~:git  config --global  credential.helper  osxkeychain

执行命令:

git push -u origin master -f

相关文章

  • git 常见问题

    问题1 : git push 问题 解决方案 git pull --tags -f解决地址: https://gi...

  • git 简单使用

    git push错误failed to push some refs to的解决 解决方案 这个问题是因为远程库与...

  • 解决git push问题

    push代码遇到如下问题: push origin master 没有权限 的时候,terminal报错没有权限。...

  • 2019-07-04

    git push :报错 413 Request Entity Too Large。 解决方案:git push ...

  • git permission deny 问题解决

    针对ATOM 的git plus, Mac电脑,git 配置完成后,atom 内的git-push无效问题的解决方...

  • 3.Git常见问题

    1.failed to push some refs to git 'git地址' 问题详情:$ git push...

  • git版本控制

    Git解决Push rejected: Push to origin/master was rejected1.g...

  • git一些小问题解决

    git一些小问题解决 Git撤销git commit 但是未git push的修改 远程删除分支 远程创建仓库 直...

  • git 入门系列(一)

    git学习-commit、push常见问题及解决措施(一) git commit 当本地修改完分支,准备将暂存区的...

  • Authentication failed for 'h

    问题1: 当我push代码到Git时,出现 上面我输入了我的全局用户名和Git的登录密码,然而问题出现 解决方法:...

网友评论

      本文标题:解决git push问题

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