zoukankan      html  css  js  c++  java
  • git同时提交到两个仓库

    有时候一个项目,希望既提交到oschina又提交到公司内网的gitlab,或者是github什么的。

    使用git remote -v 查看当前git的远程仓库。

    添加一个远程仓库

    git remote add <name> <url-of-remote>    ###<name>自己起个名字,默认是oringn,那么添加的第二个我们可以叫oschinaxxx,这样比较方便记忆是哪个源,<url of remote>是第二个git仓库的url链接。


    此时我们还不能就立即使用
    git push oschinaxxx master这样直接提交了,git会提示让我们先pull,

    此时
    git pull oschinaxxx master 还会报错,非关联的仓库不能拉下来。


    使用如下命令,添加--allow-unrelated-histories参数
    git pull oschinaxxx master --allow-unrelated-histories解决之。


    之后就可以愉快的给远程仓库push了
    git push <name of remote repository> <name of branch>,就可以push到相应的仓库了。也可以在pycahrm上直接完成这个。


    可以做成一个bat批处理脚本,来运行push
    git diff --name-only HEAD~1 HEAD
    git pull ocmtdcs master
    git pull origin master
    git push ocmtdcs master
    git push origin master
    pause







  • 相关阅读:
    CF div2 332 A
    vector resize 错误用法
    linux命令之 chown
    dlmalloc 编译 链接
    C++ 类 访问限制
    C++ 编译多态 运行多态
    libevent 编译 Windows
    浮点数小记
    NYOJ 435 棋盘覆盖(二)
    HDU 3555 Bomb 简单数位DP
  • 原文地址:https://www.cnblogs.com/ydf0509/p/7717326.html
Copyright © 2011-2022 走看看