git 多平台上传托管 & 常用命令(一)
来源:互联网 发布:php网页代码 编辑:程序博客网 时间:2024/06/09 17:00
1.首先配置不同的SSH KEY(生成key放在Windows在本地用户找到.ssh),分别添加到git和对应的git平台上(linux在git目录中 命令 ll -a 找到.ssh)添加和你本地git添加一样的公共秘钥key
2.
添加同名多远程仓库
添加一个remote,这里是all,也可以是别的名字(如origin)
git remote add all https://github.com/wonux.test.git
再添加另一个:
git remote set-url --add all https://git.oschina.net/wonux/test.git
重复向同一个远程仓库名字添加需要set-url --add
参数
如果有多个,按照上面这一个命令进行添加.
向多远程仓库推送代码
git push all --all
这样就会一次提交到多个库了,上面命令输出如下:
git push all --allUsername for 'https://github.com': wonuxPassword for 'https://wonux@github.com': Counting objects: 68, done.Delta compression using up to 4 threads.Compressing objects: 100% (56/56), done.Writing objects: 100% (68/68), 72.16 KiB | 0 bytes/s, done.Total 68 (delta 13), reused 0 (delta 0)To https://github.com/wonux/test.git * [new branch] master -> masterUsername for 'https://git.oschina.net': wonuxPassword for 'https://wonux@git.oschina.net': Counting objects: 68, done.Delta compression using up to 4 threads.Compressing objects: 100% (56/56), done.Writing objects: 100% (68/68), 72.16 KiB | 0 bytes/s, done.Total 68 (delta 13), reused 0 (delta 0)To https://git.oschina.net/wonux/test.git * [new branch] master -> master
记住不要忘记--all
参数,如果不加--all
,则无法推送,提示:
git push allwarning: push.default is unset; its implicit value has changed inGit 2.0 from 'matching' to 'simple'. To squelch this messageand maintain the traditional behavior, use: git config --global push.default matchingTo squelch this message and adopt the new behavior now, use: git config --global push.default simpleWhen push.default is set to 'matching', git will push local branchesto the remote branches that already exist with the same name.Since Git 2.0, Git defaults to the more conservative 'simple'behavior, which only pushes the current branch to the correspondingremote branch that 'git pull' uses to update the current branch.See 'git help config' and search for 'push.default' for further information.(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode'current' instead of 'simple' if you sometimes use older versions of Git)fatal: unable to access 'https://github.com/wonux/test.git/': Couldn't resolve host 'github.com'
分析配置文件
在操作完上面的添加命令后,如果我们打开.git/config
文件,我们可以看到这样的配置:
[remote "all"] url = https://github.com/wonux/test.git fetch = +refs/heads/*:refs/remotes/all/* url = https://git.oschina.net/wonux/test.git
因此,直接在.git/config
文件中添加:
[remote "all"] url = https://github.com/wonux/test.git fetch = +refs/heads/*:refs/remotes/all/* url = ……
有多少个远程库,就配置多少个url即可.
从这里可以看出,第一种方法生成的配置中还有一个fetch配置,这个配置可以完全去掉.
阅读全文
0 0
- git 多平台上传托管 & 常用命令(一)
- git 多平台上传托管 & 常用命令(二)
- git代码托管常用命令
- 使用Git上传本地项目文件带代码托管平台
- Git代码托管平台
- git代码托管平台
- Git常用命令(一)
- Git常用命令(一)
- git常用命令(一)
- Git 常用命令(一)
- #Git常用命令(一)
- 国内代码托管平台(Git)
- 国内代码托管平台(Git)
- 常用GIT代码托管平台
- Git 代码托管-项目上传
- 分布式版本控制系统Git与项目托管平台Github相关概念、操作方法、开发流程与常用命令
- 分布式管理控制系统Git与项目托管平台Github相关概念、操作方法与常用命令
- git的常用命令(一)
- 谈一谈php://input和php://output
- NumberFormatException: For input string异常处理
- 自定义圆形、圆角矩形View
- JVM监控
- kafka本地单机安装部署
- git 多平台上传托管 & 常用命令(一)
- Android E/dalvikvm: Could not find class ****** referenced from 错误
- MySQL之约束
- MFC响应组合键
- js对象与数组
- MVC的控件写法,及赋值 【重要】
- iOS GCD 线程同步方法
- msysgit +tortoisegit 安装和使用
- 深入理解 JavaScript 异步系列(4)—— Generator