git的“You can‘t push commits with committe“解决方法

本文讲述了在Git中由于使用了未注册的用户或邮箱进行提交,导致gitpush失败的问题。提供了解决方案,包括编辑或设置项目的`.git/config`,使用`gitcommit--amend`修改提交者信息,以及执行`gitpush--force`强制推送。
摘要由CSDN通过智能技术生成

如果使用错误的用户和邮箱执行了git提交,在执行 git push 时将遇到如下错误:

 ! [remote rejected] feature_116390305_story_0 -> feature_116390305_story_0 (You can't push commits with committer ‘yijian’ or email 'eyjian@qq.com' who is not exit among the registered users)
error: failed to push some refs to 'https://github.com/eyjian/sql2struct.git'

解决方法:

为项目配置正确的用户名和邮箱,这个可以直接编辑项目的 .git 子目录下的 config 文件,加上这部分信息,如:

[user]
	name = eyjian
	email = eyjian@qq.com

也可 git 命令方式设置项目的 git:

git config user.name "eyjian"
git config user.email "eyjian@qq.com"

也可设置全局的 git:

git config --global user.name "eyjian"
git config --global user.email "eyjian@qq.com"

为能够 git push 成功,还需要执行下来命令最近一次提交的用户信息:

git commit --amend --author="eyjian <eyjian@qq.com>"

然后就可执行 git push 了,如果需要强制,可以:git push --force 。

  • 6
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值