This is an old revision of the document!
Git作为VCS(Version Control System)的一种,与另一个比较有名的svn的最大区别在于Git是分布式,svn是集中式。具体来说,Git不分服务器端和客户端,只有远程仓库和本地仓库,两者完全平等,因此,Git可以离线查看日志和提交代码。
# 新手入门
很多时候并不需要每个人都创建仓库,只需要一个人创建既可。因此我们从git clone到git push到git pull的整个过程介绍Git入门。
## 推荐教程
* [Git教程|菜鸟教程](http://www.runoob.com/git/git-tutorial.html),内容简介,非常适合新手入门 * [廖雪峰Git教程](https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/),通俗易懂的中文教程 * [Pro git](https://git-scm.com/book/en/v2),纯英文,需要较好的英文阅读能力 * [码云帮助文档](http://git.mydoc.io/),使用码云做远程仓库托管服务器时可以参考,主要看其中的Git入门篇,Git进阶篇和Git操作管理
## 常用操作
* Clone远程仓库(repository):`git clone <repository_url>` * 添加untracked file:`git add <file_path>` * 提交tracked files:`git commit -m <message>` * 推送到远程仓库:`git push` * 获取最新修改:`git pull` * 查看工作区状态:`git status` * 查看日志:`git log` * 回收未提交代码:`git stash` * 恢复未提交代码:`git stash pop` * 放弃所有未提交代码(不含新增文件):`git checkout -- .` * 切换分支:`git checkout <branch_name>` * 退出git pull时跳转后的消息页面,直接输入`:q`然后敲击回车即可退出(vim编辑器)
## git生成并添加ssh公钥方法
*详见连接: http://git.mydoc.io/?t=180845
# Git flow
[Git flow创始人博客文章](http://nvie.com/posts/a-successful-git-branching-model/)
[Git flow快速入门Gitflow Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)