zoukankan      html  css  js  c++  java
  • 使用git将自己的代码同时保存在多个代码托管平台

    现在有很多代码管理平台,例如github,oschina-git,coding.net,我的网速有时候访问github比较慢。这时候我使用国内的。但是只使用一家我已不知道我的代码在他们的管理平台是否足够安全。所以我需要将我的代码同时放到多个平台

    我本地游一份代码 每次写完后。我同时推送到多个平台去,下面我使用oschina-git,和coding.net的演示

    需要自己去oschina-git或者coding.net 建立好仓库,去对应网站操作。

    但是这里注意,我们以oschina为我们的默认远程仓库,coding为备份仓库,

    我么要建立2个空仓库,不要添加readme.md和版权声明

    2 本地建立工程目录,这个目录可以先用ide建立好然后你再使用git init 初始化

    mkdir Test
    cd Test
    git init
    touch README.md
    git add README.md
    git commit -m "first commit"
    git remote add origin https://git.oschina.net/rayzhang/Test.git
    git push -u origin master //这里输入账号密码,就是你oschina-git 登陆的账号密码 ,到这里我门就将我们的代码存到了oschina-git的托管平台
    

      

      

    3将coding远程仓库加入配置文件(.git/config)

     ~/workspace/git/test/ [master] git remote add coding-remote https://coding.net/rudy/Test.git
    

    4查看一下,[coding-remote]小节就是我们添加的

    ~/workspace/git/Test/ [master] cat .git/config
    [core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
    [remote "origin"]
    url = https://git.oschina.net/rayzhang/Test.git
    fetch = +refs/heads/*:refs/remotes/origin/*
    [branch "master"]
    remote = origin
    merge = refs/heads/master
    [remote "coding-remote"]
    url = https://coding.net/rudy/Test.git
    fetch = +refs/heads/*:refs/remotes/coding-remote/*
    

      

    5 然后将代码保存到 coding.net

    git push coding-remote master //这里的coding-remote就是配置文件config[remote “coding-remote”]然后输入账号密码,和上面一样
    

    6 因为oschina是默认的仓库 更新时候 git pull 是直接去oschina-git取得,要是使用coding。net 需要 git pull coding-remote master

    7使用事例

    touch 1.java
    git add .
    git commit -m "add 1.java"
    
    git push origin
    输入账号密码
    git push coding-remote master
    输入账号密码
    

      

     相关操作问题解决,借鉴了 http://my.oschina.net/SnifferApache/blog/314880

  • 相关阅读:
    nil / Nil / NULL / NSNull
    When should I use nil and NULL in Objective-C?
    stream_context_create解析
    Linux如何通过命令查看日志文件的某几行(中间几行或最后几行)
    MySQL索引失效的几种场景
    Python网络爬虫精要
    深入Redis持久化
    SVN和Git 介绍,区别,优缺点以及适用范围
    php提示Notice: Undefined index解决方法
    在线更换背景网站(白色背景换为蓝色背景证件照)
  • 原文地址:https://www.cnblogs.com/or2-/p/4295182.html
Copyright © 2011-2022 走看看