热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

这种push如何做?

两台电脑,pc1pc2.

两台电脑,pc1 pc2.



pc1 push project1 到 https://xxxx@github.com/xxxx/...

1
2
3
4
5
git init

git add  project1/

git commit -m "from pc1"  

git remote add origin  ttps://xxxx@github.com/xxxx/yyyy.git

git push -u origin master

成功了。



现在需要将pc2上面的project2 ,push到 https://xxxx@github.com/xxxx/...
下面在pc2上使用相同的代码

1
2
3
4
5
git init

git add  project2/

git commit -m "from pc1"  

git remote add origin  https://xxxx@github.com/xxxx/yyyy.git

git push -u origin master

报错

error: failed to push some refs to 'https://xxxx@github.com/xxxx/...'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

代码修改为

1
2
3
4
5
6
7
rm -rf .git

git init

git add  project2/

git commit -m "from pc1"  

git remote add origin  https://xxxx@github.com/xxxx/yyyy.git

git pull

git push -u origin master

报错:
error: failed to push some refs to 'https://xxxx@github.com/xxxx/...'
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.

代码继续修改为

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
rm -rf .git

git init

git add  project2/

git commit -m "from pc1"  

git remote add origin  https://xxxx@github.com/xxxx/yyyy.git

git pull origin master



报错





    From https://xxxx@github.com/xxxx/yyyy.git

 * branch            master     -> FETCH_HEAD

 * [new branch]      master     -> origin/master

fatal: refusing to merge unrelated histories



git push -u origin master



报错



error: failed to push some refs to 'https://xxxx@github.com/xxxx/yyyy.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常用命令及其操作方法,包括查看、添加、提交、删除、找回等操作,以及如何重置修改文件、抛弃工作区修改、将工作文件提交到本地暂存区、从版本库中删除文件等。同时还介绍了如何从暂存区恢复到工作文件、恢复最近一次提交过的状态,以及如何合并多个操作等。 ... [详细]
  • 初始化初始化本地空版本库,仓库,英文名repositorymkdirtest&&cdtestgitinit克隆项目到本地gitclone远程同 ... [详细]
  • 先记住几个专用名词,如下:Workspace:工作区IndexStage:暂存区Repository:仓库区(或本地仓库)Remote:远程仓库一、新建代码库#在当前目录新建一个G ... [详细]
  • Git GitHub多人协作
    在学校做一个小项目需要多人协作,就用到了gitHub,百度了一下多数写得乱七八糟或者支离破碎,于是总结了一下自己的步骤如下,第一次使用GitHUb,哪里不对望大神指出一.前期准备: ... [详细]
  • 双十一在家学用 Git
    对于所有的开发者来说,掌握一门代码版本控制系统都是必须的,无论是自己做项目,团队合作,工作中的合作,都离不开版 ... [详细]
  • git向远程仓库提交遇到的各种坑
    **码云***gitinit初始化本地仓库gitinit*gitremoteaddorigingitgithub.com:xueqinngchennLocal-agent.git将 ... [详细]
  • 使用在线工具jsonschema2pojo根据json生成java对象
    本文介绍了使用在线工具jsonschema2pojo根据json生成java对象的方法。通过该工具,用户只需将json字符串复制到输入框中,即可自动将其转换成java对象。该工具还能解析列表式的json数据,并将嵌套在内层的对象也解析出来。本文以请求github的api为例,展示了使用该工具的步骤和效果。 ... [详细]
  • Za2019.8.30SDOI2011计算器[BZOJ2242][luoguP2485]1、给定y、z、p,计算y^zmodp的值;2、给定y、z、p& ... [详细]
  • 前言本篇为大家总结社区多人合作常见的场景和对应的git操作命令。本篇非新手教程,阅读本篇前需具备Git基础知识。Git入门教程请参考https://www ... [详细]
  • 注意:尽量不要直接gitpull,因为gitpull会隐藏一些中间细节,它会直接将远程主机的最新内容合并到当前分支,建议使用 ... [详细]
  • 十大经典排序算法动图演示+Python实现
    本文介绍了十大经典排序算法的原理、演示和Python实现。排序算法分为内部排序和外部排序,常见的内部排序算法有插入排序、希尔排序、选择排序、冒泡排序、归并排序、快速排序、堆排序、基数排序等。文章还解释了时间复杂度和稳定性的概念,并提供了相关的名词解释。 ... [详细]
  • 图解 Google V8 # 19 :异步编程(二):V8 是如何实现 async/await 的?
    说明图解GoogleV8学习笔记前端异步编程的方案史1、什么是回调地狱?如果在代码中过多地使用异步回调函数,会将整个代码逻辑打乱,从 ... [详细]
  • 如何在vscode中使用GitLab我同广大码友们一样,好不容易赶上了个节假日,回到家一顿安排,可屁股还没坐热就接到线上紧急BUG需要修复 ... [详细]
  • 记一次git的版本回退
    背景本地有个项目已经修改了很久(是自己的小项目不是公司的),文件挺多的,还有大量的log文件。一些资源文件是中文名,工作区修改后使用了命令gitadd.本来在.gitignore文 ... [详细]
  • 1.私有服务器搭建的环境,先clone下来了 ... [详细]
author-avatar
谦谦骄子_458
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有