Git入门指南
来源:互联网 发布:锐捷网络 路由器 编辑:程序博客网 时间:2024/06/11 23:20
第1章 Introduction
1.1 What’s git?
Git is a free & open source, distributed versioncontrol system designed to handle everything from small to very large projectswith speed and efficiency.
Every Git clone is a full-fledged repository withcomplete history and full revision tracking capabilities, not dependent onnetwork access or a central server. Branching and merging are fast and easy todo.
1.2 Download
http://git-scm.com/download
http://code.google.com/p/msysgit/downloads/list?can=3
第2章 Usage Guide
2.1 Clone arepository
The best way to get one is by using the git-clonecommand to download a copy of an existing repository:
git clone git://git.kernel.org/pub/scm/git/git.git
2.2 Checkoutfrom branch
git checkout [branchname]
2.3 Get up-to-dateresource
git pull
2.4 Add fileor directory to repository
$ git add [dir] # include everything in [dir]
$ git add path/to/file
2.5 Delete filefrom repository
$ git rm path/to/file
2.6 Commit torepository
$ git commit -m "xxx" [path/to/file | -a]
$ git status
$ git push
2.7 Merge
Merge:
$ git checkout $branch2 # To switch branch
$ git merge $branch1
$ git reset --hard HEAD … # To undo the changes,
$ git reset [commit-id] [path/to/file] # To reset a file back to an old commit
Merge conflicts:
> git pull ###failed to pull since merge conflicts
> git stash ###stash away your changes
> git pull ### this time, pull will succeedof course
> git stash pop ### yourchanges are stash back, then Auto merges will happen. And the conflict fileswill be updated by the auto merge, and got 2 persons' changes and marked withhighlights "<<<<", "=====",">>>>".
You must update the files which got conflicts. Files that got"<<<" "===" ">>>" cannot becommit or push.
# After your modification to conflicts, you can commit and push now.
> git commit -m "xxx" [file1] [file2] [file3]
> git push
2.8 Create atag
$ git tag [tag]
2.9 Create a branch
$ git branch [branch]
2.10Search a string
$ git grep xxx
2.11 Undo the last commit
git reset --hard HEAD~1
2.12 List files changed in a commit
git show --name-only $commit
2.13 View the change history of a file
git log --follow -p $file
2.14 View a file in a certain commit
git show [commit-id-7char]:[path-of-file]
2.15 Rename or move anelement in Git
git mv [dir1] [dir2]
git mv [file1] [file2]
git mv [dir1]/[file] [dir2]/[file]
Written bysmilings in GuangZhou,Apile 1th, 2012
- Git入门指南
- Git入门指南
- git入门指南
- Git LFS 入门指南
- Git入门指南 ---- Git Gui For Windows
- Git入门指南八:Git撤消操作
- 【Git入门之十五】Github操作指南
- Git入门指南七:查看提交历史
- Git入门指南十:应用标签
- 也许是最好的Git入门指南
- Git常用命令集教程指南-快速入门
- Git入门指南一:基本介绍和创建Git仓库
- Git入门指南二:初次运行Git前的配置
- Git入门指南三:Git工作流和查看文件状态
- Git入门指南十一:Git branch 分支与合并分支
- Git入门指南一:基本介绍和创建Git仓库
- Git入门指南十一:Git branch 分支与合并分支
- Git入门指南六:移除文件和移动文件
- jQuery基础教程之如何注册以及触发自定义事件
- Android Binder 机制(3)
- 使用Azure SDK 1.6 ,VM Role里加载Azure Drive方案
- 多数据源spring 报java.lang.NullPointerException
- [Android]网络资源下载时断点续传的实现
- Git入门指南
- Linux下Socket编程
- 正则表达式取正文中的汉字
- Android Binder 机制(4)
- ibatis调用oracle的动态sql
- Android中的SQLite的使用
- truncate table table_name
- 在文件中查找文本的Perl脚本
- 3 Things for Efficient Coding——简单 3 步实现高效编程