使用git push -u origin master报下面的错:
使用git push -u origin master报下面的错:
Updates were rejected because the remote contains work that you do not have locally,This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes (e.g., ‘git pull …’) before pushing again.
解决:注意你此时操作的分支为master
git pull --rebase origin master
git push -u origin master
报错二
unable to access https://github.com/1149513436/partner-back.git/ : OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054。
结合我的情况,提供两种方法,一种最简单的就是因为你现在的代码地址仓库是https形式的,你直接把仓库形式改为ssh形式就行。
举例:git remote add origin https://github.com/114XXXX6/xxx.git
改为:git remote add origin git@github.com:114xxxxxx6/xxxx.git
第二种方法重新生成公钥后再使用token令牌登录,很麻烦
提示仓库名字已经存在
origin 是重复的名字,一般出现在你第二次使用git remote add origin xxx网址时出现:
解决:
git remote rm origin
再重新git remote 啥的
git push
使用git push 报错fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
已经告诉你了使用:git push --set-upstream origin master
这条命令即可
git rm -r --cached . 清空当前文件夹的所有缓存(本地的依然保存)
git rebase origin/master
查看历史版本
git reflog
执行回滚,hard后是版本标识
git reset f8bdbf9a
//推上去
git push -f origin master
提示ssh: Could not resolve hostname github.com: No address associat
在我们使用git push origin master时报错。
完整的提示如下:
ssh: Could not resolve hostname github.com: No address associated with hostname
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
解决办法
首先打开命令行终端,使用命令ping github.com观察结果,如果是找不到github的主机地址那么可以进行下列的步骤:
- windows系统找到文件路径:C:\Windows\System32\drivers\etc,可以直接在资源管理器的最上面把这个命令输入敲回车键就能快速的找到。就是第一个hosts文件,这其实是本地 DNS 文件,用记事本打开
- 在最后一行添加命令140.82.112.4 github.com这一串数字就是github的ip地址。如何查询地址呢,点击这里即可。点击这个链接进入下方网站,在右上角输入github回车即可看见
- 之后保存这个hosts文件,继续在git bash中使用git push origin master 即可上传本地仓库文件。
参考地址:参考文章地址
一、 创建新分支以及提交步骤
1.列出所有分支
git branch -a
2.创建test分支
git branch test
3.切换到test分支:
git checkout test
4.添加add修改:
git add .
5.添加commit注释
git commit -m “第一次提交代码”
6.提交到服务器
git push origin test
Or
git push origion HEAD:refs/for/test
二、将test分支合并到master本地分支
1.创建test分支
git branch test
2.切换到test分支
git checkout test
3.在test分支添加一个readme.txt文件
touch readme.txt
git add readme.txt
4.提交commit本地文件
git commit -m “增加readme.txt”
5.切换到master分支
git checkout master
6.把test分支合并到master分支
git merge test
7.提交master分支到服务器
git push origin master
8.删除test分支
git branch -d test
fatal: refusing to merge unrelated histories
具体解决方案:
解决方案一: git clone远程仓库到本地,将需要推送的内容放到该仓库下 , 然后提交上去 , 这样算是一次update操作
解决方案二 : 使用强制命令
git pull origin master --allow-unrelated-histories
后面加上 --allow-unrelated-histories , 把两段不相干的分支进行强行合;这里可能会进入一个编辑页面,只需要先ESC,然后敲:q! 即可
后面再push就可以了 git push -u origin master