zoukankan      html  css  js  c++  java
  • 已有项目迁入git 并设置远程仓库

    1.项目根路径下,初始化本地仓库
    git init

    2.连接到远程仓库,并将代码同步到远程仓库
    git remote add origin 远程仓库地址

    连接到远程仓库并为该仓库创建别名 , 别名为origin . 这个别名是自定义的,通常用origin ; 远程仓库地址,就是你自己新建的那个仓库的地址
    如:git remote add origin https://github.com/CnPeng/MyCustomAlertDialog.git 这段代码的含义是: 连接到github上https://github.com/CnPeng/MyCustomAlertDialog.git 这个仓库,并创建别名为origin . (之后push 或者pull 的时候就需要使用到这个 origin 别名)

    3.设置git push 和 pull 默认分支
    git branch --set-upstream-to=origin/dev dev

    问题解决方案:
    如果遇到git无法pull仓库refusing to merge unrelated histories
    我在Github新建一个仓库,写了License,然后把本地一个写了很久仓库上传。
    先pull,因为两个仓库不同,发现refusing to merge unrelated histories,无法pull
    因为他们是两个不同的项目,要把两个不同的项目合并,git需要添加一句代码,在git pull,这句代码是在git 2.9.2版本发生的,最新的版本需要添加--allow-unrelated-histories
    假如我们的源是origin,分支是master,那么我们 需要这样写git pull origin master ----allow-unrelated-histories需要知道,我们的源可以是本地的路径

  • 相关阅读:
    完美主义之我见
    职场-位置思维
    我的读书观
    人力资源是组织的第一战略资源-论基层员工
    积累是做成事情得唯一途径
    地理信息数据处理之我见
    word 之 插入删除空行
    OSMeteorTranslationAPI(百度,有道)对比
    CsharpOSMeteorCodeGenerator(Metero代码生成器)
    HtmlDOM 文档读取研究
  • 原文地址:https://www.cnblogs.com/guihuo/p/7467949.html
Copyright © 2011-2022 走看看