the5fire

关注Python、Django、Vim、Linux、Web开发、团队管理和互联网--Life is short, we need Python.


上传代码到github上及git常用命令

作者:the5fire | 标签:     | 发布:2012-07-31 11:15 p.m. | 阅读量: 15263, 15020
在项目开发中git常用的命令就那几个,罗列到下面:

基本的命令:
0、在github上创建testgit的库

1、git init //初始化一个代码库

2、git add filename.py //添加文件到版本库

3、git commit -m 'add filename.py to src' //提交,产生版本记录,注意代码依然在本地

远程库操作:
1、git remote add origin git://github.com/the5fire/testgit.git

2、git pull origin

3、git remote add origin git@github.com:[yourname]/testgit.git //这样设置之后才可以提交代码,目前不知何故

3.1、补充:编辑.git/config 添加:

[branch "master"]
remote = origin
merge = refs/head/master


3.2、git pull

4、git push origin //将代码提交到远程

分支操作:
1、创建分支

​git branch [name]

2、删除分支

git branch -d [name]

3、切换分支

git checkout [name]


4、合并分支

git merge [name] 把分支[name]合并到当前分支

可以通过版本回退来完成取消merge

基本就这些,以后有用到的再来补充。
- from the5fire.com
----EOF-----

微信公众号:Python程序员杂谈


其他分类: