美文网首页
Git-33: 本地仓库同步到Github

Git-33: 本地仓库同步到Github

作者: WenxuanLi | 来源:发表于2019-04-04 12:13 被阅读0次

    李文轩 2019-02-27


    Remote:

    $ git remote -v 
    # 查看远程版本库信息
        
    $ git remote add <repo-name> <repo-url>
    # 添加<repo-name>远程版本库
    # repo-name 仅供本地使用
    

    Sync:

    # "git pull" 其实是 "git fetch" 和 "git merge" 的一个捷径
        
    $ git fetch <repo-name>
    # 拉取远程版本库
        
    $ git merge -h #查看 merge 命令帮助
        
    $ git merge --allow-unrelated-histories <repo-name>/<branch-name>
    # 演示用的命令
    # 因为 本地<branch-name>分支指针 和 远端<branch-name>分支指针不是同一个 parent
    # 合并之后,生成一个新的 merge的commit
    # 本地<branch-name>指针指向这个commit
    # 远端<branch-name>指针指向这个commit的远端的parent
    # 此时,新merge的commit 有两个paren
        
    $ git push <repo-name>
    # 同步到<repo-name>
    # 此时,本地与远端的<branch-name>指针同时指向这个commit(理想状态)
    

    相关文章

      网友评论

          本文标题:Git-33: 本地仓库同步到Github

          本文链接:https://www.haomeiwen.com/subject/aqefiqtx.html