zoukankan      html  css  js  c++  java
  • 链接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

  • 相关阅读:
    JVM学习-垃圾回收算法
    JVM学习-jvm判断对象已死的方法
    JVM学习-jvm内存区域
    python 多线程
    Python+unittest+requests+excel实现接口自动化测试框架
    linux 运行tensorflow文件缺少_bz2问题及解决
    获取url地址
    微信小程序的小问题(2)
    微信小程序的小问题(1)
    前端知识
  • 原文地址:https://www.cnblogs.com/hjworld/p/12250191.html
Copyright © 2011-2022 走看看