使用 Git@OSC 管理代码
2016-03-12 10:21
513 查看
开源中国的 git 服务的地址是:http://git.oschina.net/
以下记录 push 本地已有的项目至 git@osc 的过程。
① 注册登录之后,创建一个自己的项目:
创建好的默认项目中包含一个 README.md 文件,用于项目的描述,使用 Markdown 编辑。
② 生成 ssh-key
在 linux 下生成 ssh 公钥:
公钥保存的位置是 ~/.ssh/id_rsa.pub
查看并复制公钥:
把私钥的内容复制到 oschina 的 SSH 公钥中:
保存。
可以通过下面的命令查看公钥是否配置成功。
输出:
③ 提交代码
进入本地项目,将目录转化为 Git 版本库
添加项目中所有的 file 至版本库
提交:
添加到远程版本库,也就是 git@osc
如果版本库中已有文件,在使用 push 命令的时候报错:
则先要把远程仓库中的文件 fetch 到本地然后再 merge,这两步相当于 git pull
如果出现以下信息:
则输入以下命令即可:
说明:
1 当你处于 master branch,默认的 remote 就是 origin
2 当你在 master branch 上使用 git pull 时,没有指定 remote 和 branch,那么 git 就会采用默认的 remote(也就是origin)来 merge 在 master branch 上所有的改变
参考:
http://git.oschina.net/oschina/git-osc/wikis/home
http://git.oschina.net/wzw/git-quick-start
配置ssh公钥访问oschina
github上传时出现error: src refspec master does not match any解决办法
Git错误non-fast-forward后的冲突解决
以下记录 push 本地已有的项目至 git@osc 的过程。
① 注册登录之后,创建一个自己的项目:
创建好的默认项目中包含一个 README.md 文件,用于项目的描述,使用 Markdown 编辑。
② 生成 ssh-key
在 linux 下生成 ssh 公钥:
[root@localhost ~]# ssh-keygen
公钥保存的位置是 ~/.ssh/id_rsa.pub
查看并复制公钥:
[root@localhost ~]# cat ~/.ssh/id_rsa.pub
把私钥的内容复制到 oschina 的 SSH 公钥中:
保存。
可以通过下面的命令查看公钥是否配置成功。
[root@localhost ~]# ssh -T git@git.oschina.net
输出:
③ 提交代码
进入本地项目,将目录转化为 Git 版本库
[root@localhost practise]# git init
添加项目中所有的 file 至版本库
[root@localhost practise]# git add .
提交:
[root@localhost practise]# git commit -m 'add practise files'
添加到远程版本库,也就是 git@osc
[root@localhost practise]# git remote add origin git@git.oschina.net:dee0912/practise.git
[root@localhost practise]# git push -u origin master
如果版本库中已有文件,在使用 push 命令的时候报错:
To git@git.oschina.net:dee0912/practise.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@git.oschina.net:dee0912/practise.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.
则先要把远程仓库中的文件 fetch 到本地然后再 merge,这两步相当于 git pull
[root@localhost practise]# git fetch [root@localhost practise]# git merge
如果出现以下信息:
[root@localhost practise]# git merge usage: git merge [options] <remote>... or: git merge [options] <msg> HEAD <remote>
则输入以下命令即可:
[root@localhost practise]# git config branch.master.remote origin [root@localhost practise]# git config branch.master.merge refs/heads/master [root@localhost practise]# git pull
说明:
1 当你处于 master branch,默认的 remote 就是 origin
2 当你在 master branch 上使用 git pull 时,没有指定 remote 和 branch,那么 git 就会采用默认的 remote(也就是origin)来 merge 在 master branch 上所有的改变
参考:
http://git.oschina.net/oschina/git-osc/wikis/home
http://git.oschina.net/wzw/git-quick-start
配置ssh公钥访问oschina
github上传时出现error: src refspec master does not match any解决办法
Git错误non-fast-forward后的冲突解决
相关文章推荐
- 关于 AlphaGo 论文的阅读笔记
- 动态链表
- C++中引用(&)的用法和应用实例
- QML中Grid定位器
- VC++与Matlab混合编程之引擎操作详解
- QML中Column的使用及示例
- django url.py name字段
- Java的各种操作
- QML中ROW组件的使用方法及示例
- C-C++字符输出时遇到字符'\n','\0'区别
- Python发送邮件小析
- C-C++字符输出时遇到字符'\n','\0'区别
- 2016蓝桥杯假期任务之《十六进制转十进制》
- Java 序列化Serializable初探1
- Spring中配置和读取多个Properties文件
- 写两个线程,一个线程打印 1~52,另一个线程打印字母A-Z。打印顺序为12A34B56C……5152Z
- c++中 vs 简单的对txt文件读写
- windows10 系统下为python配置numpy和scipy
- 比较有用的php代码片段
- Mac配置Qt环境——Could not resolve SDK path for 'macosx10.8'