打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
链接github

引用https://www.cnblogs.com/u-1596086/p/11588957.html
第一步:登录git创建项目

右上角头像按钮,点击your repositories

接着绿色按钮:new

接着就是命名,再点击create respositoory,就在git上创建好了项目。

第二步,关联远程仓库

1,创建成功之后,我们会看到仓库的地址,如下:git@github.com:lenve/test.git,然后我需要将我们之前的本地仓库和这个远程仓库进行关联,使用git remote add命令,如下:

$ git remote add origin git@github.com:lenve/test.git

在这条命令中,git会自动将远程仓库的名字设置为origin,方便我们的后续操作。

2,假设我想将本地master分支上的内容推送到远程master分支上,方式如下:

$ git push -u origin master
如果想推送到其他分支,还是这条命令,修改一下分支的名字即可,比如我也想把我的fa分支推送到远程仓库中,执行如下命令:

$ git checkout fire
$ git push -u origin fire

引用https://blog.csdn.net/sinat_36246371/article/details/79738782(原文链接)
在执行git pull的时候,提示当前branch没有跟踪信息:

git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
1
2
3
对于这种情况有两种解决办法,就比如说要操作master吧,一种是直接指定远程master:

git pull origin master
1
另外一种方法就是先指定本地master到远程的master,然后再去pull:

git branch --set-upstream-to=origin/master master
git pull
1
2
这样就不会再出现“There is no tracking information for the current branch”这样的提示了。

引用https://www.centos.bz/2018/03/git-%E5%87%BA%E7%8E%B0-fatal-refusing-to-merge-unrelated-histories-%E9%94%99%E8%AF%AF/

git pull 失败 ,提示:fatal: refusing to merge unrelated histories

其实这个问题是因为 两个 根本不相干的 git 库, 一个是本地库, 一个是远端库, 然后本地要去推送到远端, 远端觉得这个本地库跟自己不相干, 所以告知无法合并

具体的方法, 一个种方法: 是 从远端库拉下来代码 , 本地要加入的代码放到远端库下载到本地的库, 然后提交上去 , 因为这样的话, 你基于的库就是远端的库, 这是一次update了

第二种方法:
使用这个强制的方法

git pull origin master --allow-unrelated-histories

后面加上 --allow-unrelated-histories , 把两段不相干的 分支进行强行合并

后面再push就可以了 git push gitlab master:init

gitlab是别名 , 使用

Java代码
git remote add gitlab ssh://xzh@192.168.1.91:50022/opt/gitrepo/withholdings/WithholdingTransaction

master是本地的branch名字
init是远端要推送的branch名字

本地必须要先add ,commit完了 才能推上去

关于这个问题,可以参考http://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories。

在进行git pull 时,添加一个可选项

git pull origin master --allow-unrelated-histories

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
如何去解决fatal: refusing to merge unrelated histories
Git查看、删除、重命名远程分支和tag | zrong's blog
Github 简明教程 | 菜鸟教程
Github 上的项目到底是怎么合作的?Git flow 操作流程详解
Git
Git 追踪分支
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服