git提交远程报错[rejected] master -> master (fetch first)

1 先下载git for windows

然后一直点下一步安装.

2 安装之后,选择git gui.生成ssh 链接 git 公钥.

用命令也可以:

$ ssh-keygen -t rsa -C "[email protected]"

然后输入密码.

建议用第一种方式。第二种网上说是可以,但是我没成功过。

然后输入密码。

3 将公钥添加到开源中国上,或者是github中

在开源中国中新建一个公钥,然后将.ssh文件夹下的id_ras_pub中的内容复制到文本框中,这里的title可以随意.

4 测试链接:

输入命令:$ ssh -T [email protected]

然后输入yes

如果成功可以看到你的用户名和邮箱.

出现错误可以测试:$ ssh -Tv [email protected]

5 设置用户名和邮箱

$ git  config user.name"you name"

$git  config user.email"[email protected]"

6 然后在web开源中国中创建一个project.

7 测试上传文件

创建文件夹,需要和你建立的projexct同名。

mkdir hello

cd hello

git init

touch README

git add README

git commit  -m  ‘frist commit‘

8 提交

git remote add test [email protected]:web用户名/hell.git

git push -u test master

如里有报错误:

To [email protected]:yangzhi/hello.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to ‘[email protected]:yangzhi/hello.git‘
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushin
hint: to the same ref. You may want to first merge 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 -f

可以ok了.

10 克隆代码

git clone [email protected]:用户名/项目名.git

来源:http://www.xuebuyuan.com/651322.html

时间: 2024-08-03 04:03:01

git提交远程报错[rejected] master -> master (fetch first)的相关文章

git提交是报错没有change-id的解决方法

git提交是报错没有change-id的解决方法: 1.先仔细查看报错内容,查出是哪天提交记录缺少change-id 2.如果是最近的一条缺少,则直接执行git commit --amend "提交信息",以对上次提交的内容进行修改: 如果是前面几条都缺少change-id,则先 git reset --soft ****ddfd(恢复到最近一次有change-id的提交记录),重新提交$ git commit -am "提交信息" 重新提交修改记录 3.执行git

Git添加远程报错:remote origin already exists.

在本地创建了一个Git仓库,如何在Github创建一个Git仓库,并且让这两个仓库进行远程同步,这样Github上的仓库既可以作为备份仓库,还可以通过该仓库进行多人协作. 1.登录github,建立一个新的仓库 2.添加仓库名字 3根据Github的提示,在本地的learngit仓库下运行命令 1 $ git remote add origin [email protected]:zhanghuming/learngit.git 4.把本地库的所有内容推送到远程库上 1 $ git push -

git提交代码报错 trailing whitespace的解决方法

禁止执行pre-commit脚本 进入到项目目录中 chmod a-x .git/hooks/pre-commit 原文地址:https://www.cnblogs.com/wt11/p/8260107.html

git提交代码报错Permission denied, please try again

一. 之前一直可以正常使用,突然出现Permission denied, please try again,重试了很多次,最后使用了笨的方法,忘记密码,重新设置了新密码,然后在重新生成了ssh,解决成功 二. gitLab 设置SSH的方法 1. 查看秘钥是否存在 $cd ~/.ssh 2. 生成秘钥 $ssh-keygen -t rsa -C "[email protected]" 3. 查看SSH $cat id_rsa.pub 4. 找到settings 5. 点击SSH key

git连接不上远程仓库---visualstudio提交代码报错:no upstream configured for branch 'master'

1,新建文件夹,在文件下下鼠标右键git bush--->git init,初始化仓库: 2,设置gitthub仓库地址:git remote add origin https://github.com/z*****g/lm.git 3,git pull origin master 4,git push --set-upstream origin master,关联一个远程分支,并从这个分支上传下带代码 git branch查看分支 git add . git commit -m "提交注

git push -u origin master报错src refspec master does

git push -u origin master 时候报错 src refspec master does not match any. 因为[email protected]上面没有版本分支master,首先要去到目标目录,随便git add一个文件,然后git commit -m "msg".提交到了( 在commit之前要 git config --global user.name "forai" git config --global user.email

MyEclipse8.6中提交SVN报错

上周五(11月27日)的时候,从TortoiseSVN提交项目报错,然后直接从MyEclipse中检出来,修改后提交同样报错. MyEclipse8.6中提交SVN报错,错误提示如下: commit -m "车牌号码中的字母自动转为大写" C:/Workspaces/VIMSystem/src/com/anche/action/ActIcRecord.java svn: Commit failed (details follow): svn: Can't write activity

git同步遇到报错“fatal: unable to access 'https://github.com/ruanwenwu/newp.git/': Peer reports incompatible or unsupported protocol version.”

git同步遇到报错"fatal: unable to access 'https://github.com/ruanwenwu/newp.git/': Peer reports incompatible or unsupported protocol version." 网上很多人说是因为git版本需要升级.我将git版本升级到最新, [[email protected] tp5test]# git --version git version 2.16.2 问题却依然存在. 最后: y

git同步遇到报错“fatal: unable to access 'https://github.com/lizhong24/mysite2.git/': Peer reports incompatible or unsupported protocol version.”

git同步遇到报错"fatal: unable to access 'https://github.com/lizhong24/mysite2.git/': Peer reports incompatible or unsupported protocol version." 解决办法: yum update -y nss curl libcurl 问题解决了. git同步遇到报错"fatal: unable to access 'https://github.com/liz