Git总结笔记4-git push origin master 报错的解决方法

 1 错误提示如下:
 2 [[email protected] php]# git push -u origin master
 3 To [email protected]:kangvcar/Results-Systems--PHP.git
 4  ! [rejected]        master -> master (fetch first)
 5 error: failed to push some refs to ‘[email protected]:kangvcar/Results-Systems--PHP.git‘
 6 hint: Updates were rejected because the remote contains work that you do
 7 hint: not have locally. This is usually caused by another repository pushing
 8 hint: to the same ref. You may want to first merge the remote changes (e.g.,
 9 hint: ‘git pull‘) before pushing again.
10 hint: See the ‘Note about fast-forwards‘ in ‘git push --help‘ for details.

原因:

GitHub远程仓库中的README.md文件不在本地仓库中。

解决方案1:

我们只需加上 -f 参数即可push成功。

 1 [[email protected] qimo]# git push -f
 2 warning: push.default is unset; its implicit value is changing in
 3 Git 2.0 from ‘matching‘ to ‘simple‘. To squelch this message
 4 and maintain the current behavior after the default changes, use:
 5
 6   git config --global push.default matching
 7
 8 To squelch this message and adopt the new behavior now, use:
 9
10   git config --global push.default simple
11
12 See ‘git help config‘ and search for ‘push.default‘ for further information.
13 (the ‘simple‘ mode was introduced in Git 1.7.11. Use the similar mode
14 ‘current‘ instead of ‘simple‘ if you sometimes use older versions of Git)
15
16 Counting objects: 53, done.
17 Compressing objects: 100% (53/53), done.
18 Writing objects: 100% (53/53), 1.35 MiB | 55.00 KiB/s, done.
19 Total 53 (delta 8), reused 0 (delta 0)
20 remote: Resolving deltas: 100% (8/8), done.
21 To [email protected]:kangvcar/Results-Systems--PHP.git
22  + fbe05e8...70b187d master -> master (forced update)

解决方案2:

我们只需加上 --rebase 参数然后再重新 push 一次即可。

1 [[email protected] qimo]# git pull --rebase origin master
2 [[email protected] qimo]# git push -u origin master
时间: 2024-07-31 19:03:13

Git总结笔记4-git push origin master 报错的解决方法的相关文章

git push origin master 报错 remote rejected] master -> master (branch is currently checked out)

解决办法: 977down vote You can simply convert your remote repository to bare repository (there is no working copy in the bare repository - the folder contains only the actual repository data). Execute the following command in your remote repository folde

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

更换仓库地址后,git fetch origin master报错

1.问题描述: 今天服务器迁移了下git,于是就直接根据拷贝后的git repo创建了远程仓库,本来一切都很顺利. 服务器端执行命令报错.记录下解决过程 2.执行命令报错 $ git fetch origin master @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @ @@@@@@@@@@@@@@@@@@

提交代码出现 Push to origin/master was rejected 错误解决方法

原文地址:https://www.cnblogs.com/wurendao/p/11732876.html 为什么会出现这样的问题 一般发生在 GitHub 或 码云 刚刚创建仓库第一次pull的时候,两个仓库的差别非常大,所以git拒绝合并两个不相干的东西 快速解决方法 切换到自己项目所在的目录,右键选择GIT BASH Here  然后依次输入一下命令即可解决 git pull git pull origin master git pull origin master --allow-unr

git 报错git-upload-pack 解决方法

报错如下: bash: git-upload-pack: command not foundfatal: The remote end hung up unexpectedly 原因:原来代码服务器上的git安装路径是/usr/local/git,不是默认路径,根据提示,在git服务器上, 建立链接文件: 解决方法: # ln -s /usr/local/git/bin/git-upload-pack /usr/bin/git-upload-pack 再次执行 git clone 成功! 报错如

git push origin master出错:error: failed to push some refs to

1.输入git push origin master 出错:error: failed to push some refs to 那是因为本地没有update到最新版本的项目(git上有README.md文件没下载下来) 本地直接push所以会出错. 2.所以本地要输入git pull 然后出现的英语提示'git pull <repository> <refspec>'显示要选择远程分支 2.就试试指定目标到远程分支 输入git pull origin 出现提示 but did n

git push origin master

touch README.mdgit initgit add README.mdgit commit -m "first commit"git remote add origin [email protected]:joojfork/Linuxyunwei.gitgit push -u origin master git remote add origin [email protected]:joojfork/Linuxyunwei.gitgit push -u origin mast

delete master error(git push origin :master)

All good so far. We next want to delete the branch on github. However, if we do this the naive way: git push origin :master we just get an error like this: remote: error: refusing to delete the current branch: refs/heads/master To [email protected]:m

git push origin master 遇到的分支问题

我从master分支创建了一个issue1分支,做了一些修改后,使用git push origin master提交,但是显示的结果却是'Everything up-to-date', 发生问题的原因是git push origin master 在没有track远程分支的本地分支中默认提交的master分支,因为master分支默认指向了origin master 分支, 这里要使用git push origin issue1:master 就可以把issue1推送到远程的master分支了