Git命令行使用
2016-01-31 15:31
477 查看
摘要:之前一直使用Eclipse中的GIt插件进行版本控制,忽略了Git命令行的使用,进入公司之后才发现开发中git命令使用的重要性,故通过查找资料,对Git命令行进行整理。
[- -exec-path [=< path>]] [- - html-path] [- - man-path] [- -info-path]
[-p | –paginate | - - no-pager] [- -no-replace-objects] [- - bare]
[- - git-dir=< path>] [- -work-tree=< path>] [–namespace=< name>]
< command> [< args>]
git-help : 显示git的帮助信息
git init [-q | –quiet] [–bare] [–template=< template_directory>]
[–separate-git-dir < git dir>]
[–shared[=< permissions>]] [directory]
git clone:克隆一个仓库到当前目录下
git clone [- -template=< template_directory>]
[-l] [-s] [- -no-hardlinks] [-q] [-n] [–bare] [- -mirror]
[-o < name>] [-b < name>] [-u < upload-pack>] [- -reference < repository>]
[- -dissociate] [- -separate-git-dir < git dir>]
[- -depth < depth>] [- -[no-]single-branch]
[- -recursive | - -recurse-submodules] [–] < repository>
[< directory>]
git add [- -verbose | -v] [- -dry-run | -n] [- -force | -f] [–interactive | -i] [- -patch | -p]
[- -edit | -e] [- -[no-]all | - -[no-]ignore-removal | [- -update | -u]]
[- -intent-to-add | -N] [- -refresh] [- -ignore-errors] [- -ignore-missing]
[- -] [< pathspec>…]
git status : 查看当前Git仓库索引中文件的状态,是否被管理,修改等。
git status [< options>…] [- -] [< pathspec>…]
git diff : 对比本地仓库与远程仓库的变化
git diff [options] [< commit>] [- -] [< path>…]
git diff [options] - -cached [< commit>] [- -] [< path>…]
git diff [options] < commit> [- -] [< path>…]
git diff [options] < blob> < blob>
git diff [options] [- -no-index] [- -] < path> < path>
git commit: 保存当前仓库索引文件的修改。
git commit [-a | - -interactive | - -patch] [-s] [-v] [-u< mode>] [- -amend]
[- -dry-run] [(-c | -C | –fixup | - -squash) < commit>]
[-F < file> | -m < msg>] [- -reset-author] [- -allow-empty]
[- -allow-empty-message] [- -no-verify] [-e] [- -author=< author>]
[- -date=< date>] [- -cleanup=< mode>] [- -[no-]status]
[-i | -o] [-S[< keyid>]] [- -] [< file>…]
git reset : 从暂存区恢复工作文件
git reset [-q] [< tree-ish>] [- -] < paths>…
git reset (- -patch | -p) [< tree-ish>] [- -] [< paths>…]
git reset [- -soft | - -mixed [-N] | - -hard | - -merge | - -keep] [-q] [< commit>]
git rm : 将文件从当前仓库管理的索引中移除
git rm [-f | - -force] [-n] [-r] [- -cached] [- -ignore-unmatch] [–quiet] [- -] < file>…
git mv : 移动或重命名文件,目录或符号链接
git mv < options>… < args>…
git branch [- -color[=< when>] | - -no-color] [-r | -a]
[- -list] [-v [- -abbrev=< length> | - -no-abbrev]]
[- -column[=< options>] | - -no-column]
[(- -merged | - -no-merged | - -contains) [< commit>]] [- -sort=< key>]
[- -points-at < object>] [< pattern>…]
git branch [- -set-upstream | - -track | - -no-track] [-l] [-f] < branchname> [< start-point>]
git branch (- -set-upstream-to=< upstream> | -u < upstream>) [< branchname>]
git branch - -unset-upstream [< branchname>]
git branch (-m | -M) [< oldbranch>] < newbranch>
git branch (-d | -D) [-r] < branchname>…
git branch - -edit-description [< branchname>]
git checkout : 切换分支或恢复当前工作区的文件
git checkout [-q] [-f] [-m] [< branch>]
git checkout [-q] [-f] [-m] - -detach [< branch>]
git checkout [-q] [-f] [-m] [- -detach] < commit>
git checkout [-q] [-f] [-m] [[-b|-B|- -orphan] < new_branch>] [< start_point>]
git checkout [-f|- -ours|- -theirs|-m|- -conflict=< style>] [< tree-ish>] [- -] < paths>…
git checkout [-p|- -patch] [< tree-ish>] [- -] [< paths>…]
git merge : 合并分支
git merge [-n] [- -stat] [- -no-commit] [- -squash] [- -[no-]edit]
[-s < strategy>] [-X < strategy-option>] [-S[< keyid>]]
[- -[no-]rerere-autoupdate] [-m < msg>] [< commit>…]
git merge < msg> HEAD < commit>…
git merge - -abort
git mergetool : 运行合并和解决冲突的工具来解决合并冲突
git mergetool [- -tool=< tool>] [-y | - -[no-]prompt] [< file>…]
git log : 查看提交更改记录
git log [< options>] [< revision range>] [[\–] < path>…]
git stash : 将当前的变化暂存到新目录下
git stash list [< options>]
git stash show [< stash>]
git stash drop [-q|- -quiet] [< stash>]
git stash ( pop | apply ) [- -index] [-q|- -quiet] [< stash>]
git stash branch < branchname> [< stash>]
git stash [save [-p|- -patch] [-k|- -[no-]keep-index] [-q|- -quiet]
[-u|- -include-untracked] [-a|–all] [< message>]]
git stash clear
git stash create [< message>]
git stash store [-m|- -message < message>] [-q|- -quiet] < commit>
git tag : 创建、列表、删除或验证一个GPG签署的标签对象
git tag [-a | -s | -u < keyid>] [-f] [-m | -F < file>]
< tagname> [< commit> | < object>]
git tag -d < tagname>…
git tag [-n[< num>]] -l [- -contains < commit>] [- -points-at < object>]
[- -column[=< options>] | - -no-column] [- -create-reflog] [- -sort=< key>]
[- -format=< format>] [- -[no-]merged [< commit>]] [< pattern>…]
git tag -v < tagname>…
git fetch [< options>] [< repository> [< refspec>…]]
git fetch [< options>] < group>
git fetch - -multiple [< options>] [(< repository> | < group>)…]
git fetch - -all [< options>]
git pull : 从其他仓库或本地分支中获取并整合进当前仓库
git pull [options] [< repository> [< refspec>…]]
git push : 将当前提交的修改更新到远程绑定的仓库
git push [- -all | - -mirror | - -tags] [- -follow-tags] [- -atomic] [-n | - -dry-run] [- -receive-pack=< git-receive-pack>]
[- -repo=< repository>] [-f | - -force] [- -prune] [-v | - -verbose]
[-u | - -set-upstream]
[- -[no-]signed|- -sign=(true|false|if-asked)]
[- -force-with-lease[=< refname>[:< expect>]]]
[- -no-verify] [< repository> [< refspec>…]]
git remote : 管理远程仓库
git remote [-v | - -verbose]
git remote add [-t < branch>] [-m < master>] [-f] [- -[no-]tags] [- -mirror=< fetch|push>] < name> < url>
git remote rename < old> < new>
git remote remove < name>
git remote set-head < name> (-a | - -auto | -d | - -delete | < branch>)
git remote set-branches [- -add] < name> < branch>…
git remote get-url [- -push] [- -all] < name>
git remote set-url [- -push] < name> < newurl> [< oldurl>]
git remote set-url - -add [- -push] < name> < newurl>
git remote set-url - -delete [- -push] < name> < url>
git remote [-v | - -verbose] show [-n] < name>…
git remote prune [-n | - -dry-run] < name>…
git remote [-v | - -verbose] update [-p | - -prune] [(< group> | < remote>)…]
git submodule : 初始化,更新或检查子模块
Git命令详解
Git常用命令
Git基本命令行操作
Git-Reference
Git概述
Git是一个分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。其他版本控制系统包括CVS,SVN。$ git
usage: git [- -version ] [- -help] [-C < path>] [-c name=value][- -exec-path [=< path>]] [- - html-path] [- - man-path] [- -info-path]
[-p | –paginate | - - no-pager] [- -no-replace-objects] [- - bare]
[- - git-dir=< path>] [- -work-tree=< path>] [–namespace=< name>]
< command> [< args>]
Git Reference
设置与配置(Setup and Config)
git-config : 获取和设置仓库或全局选项git-help : 显示git的帮助信息
创建和获取项目(Getting and Creating Projects)
git init : 创建一个新的Git仓库或初始化现有仓库git init [-q | –quiet] [–bare] [–template=< template_directory>]
[–separate-git-dir < git dir>]
[–shared[=< permissions>]] [directory]
git clone:克隆一个仓库到当前目录下
git clone [- -template=< template_directory>]
[-l] [-s] [- -no-hardlinks] [-q] [-n] [–bare] [- -mirror]
[-o < name>] [-b < name>] [-u < upload-pack>] [- -reference < repository>]
[- -dissociate] [- -separate-git-dir < git dir>]
[- -depth < depth>] [- -[no-]single-branch]
[- -recursive | - -recurse-submodules] [–] < repository>
[< directory>]
常用基本命令
git add : 将文件添加到当前Git仓库的索引中,让Git进行管理git add [- -verbose | -v] [- -dry-run | -n] [- -force | -f] [–interactive | -i] [- -patch | -p]
[- -edit | -e] [- -[no-]all | - -[no-]ignore-removal | [- -update | -u]]
[- -intent-to-add | -N] [- -refresh] [- -ignore-errors] [- -ignore-missing]
[- -] [< pathspec>…]
git status : 查看当前Git仓库索引中文件的状态,是否被管理,修改等。
git status [< options>…] [- -] [< pathspec>…]
git diff : 对比本地仓库与远程仓库的变化
git diff [options] [< commit>] [- -] [< path>…]
git diff [options] - -cached [< commit>] [- -] [< path>…]
git diff [options] < commit> [- -] [< path>…]
git diff [options] < blob> < blob>
git diff [options] [- -no-index] [- -] < path> < path>
git commit: 保存当前仓库索引文件的修改。
git commit [-a | - -interactive | - -patch] [-s] [-v] [-u< mode>] [- -amend]
[- -dry-run] [(-c | -C | –fixup | - -squash) < commit>]
[-F < file> | -m < msg>] [- -reset-author] [- -allow-empty]
[- -allow-empty-message] [- -no-verify] [-e] [- -author=< author>]
[- -date=< date>] [- -cleanup=< mode>] [- -[no-]status]
[-i | -o] [-S[< keyid>]] [- -] [< file>…]
git reset : 从暂存区恢复工作文件
git reset [-q] [< tree-ish>] [- -] < paths>…
git reset (- -patch | -p) [< tree-ish>] [- -] [< paths>…]
git reset [- -soft | - -mixed [-N] | - -hard | - -merge | - -keep] [-q] [< commit>]
git rm : 将文件从当前仓库管理的索引中移除
git rm [-f | - -force] [-n] [-r] [- -cached] [- -ignore-unmatch] [–quiet] [- -] < file>…
git mv : 移动或重命名文件,目录或符号链接
git mv < options>… < args>…
分支与合并(Branching and Merging)
git branch : 查看,删除,创建分支git branch [- -color[=< when>] | - -no-color] [-r | -a]
[- -list] [-v [- -abbrev=< length> | - -no-abbrev]]
[- -column[=< options>] | - -no-column]
[(- -merged | - -no-merged | - -contains) [< commit>]] [- -sort=< key>]
[- -points-at < object>] [< pattern>…]
git branch [- -set-upstream | - -track | - -no-track] [-l] [-f] < branchname> [< start-point>]
git branch (- -set-upstream-to=< upstream> | -u < upstream>) [< branchname>]
git branch - -unset-upstream [< branchname>]
git branch (-m | -M) [< oldbranch>] < newbranch>
git branch (-d | -D) [-r] < branchname>…
git branch - -edit-description [< branchname>]
git checkout : 切换分支或恢复当前工作区的文件
git checkout [-q] [-f] [-m] [< branch>]
git checkout [-q] [-f] [-m] - -detach [< branch>]
git checkout [-q] [-f] [-m] [- -detach] < commit>
git checkout [-q] [-f] [-m] [[-b|-B|- -orphan] < new_branch>] [< start_point>]
git checkout [-f|- -ours|- -theirs|-m|- -conflict=< style>] [< tree-ish>] [- -] < paths>…
git checkout [-p|- -patch] [< tree-ish>] [- -] [< paths>…]
git merge : 合并分支
git merge [-n] [- -stat] [- -no-commit] [- -squash] [- -[no-]edit]
[-s < strategy>] [-X < strategy-option>] [-S[< keyid>]]
[- -[no-]rerere-autoupdate] [-m < msg>] [< commit>…]
git merge < msg> HEAD < commit>…
git merge - -abort
git mergetool : 运行合并和解决冲突的工具来解决合并冲突
git mergetool [- -tool=< tool>] [-y | - -[no-]prompt] [< file>…]
git log : 查看提交更改记录
git log [< options>] [< revision range>] [[\–] < path>…]
git stash : 将当前的变化暂存到新目录下
git stash list [< options>]
git stash show [< stash>]
git stash drop [-q|- -quiet] [< stash>]
git stash ( pop | apply ) [- -index] [-q|- -quiet] [< stash>]
git stash branch < branchname> [< stash>]
git stash [save [-p|- -patch] [-k|- -[no-]keep-index] [-q|- -quiet]
[-u|- -include-untracked] [-a|–all] [< message>]]
git stash clear
git stash create [< message>]
git stash store [-m|- -message < message>] [-q|- -quiet] < commit>
git tag : 创建、列表、删除或验证一个GPG签署的标签对象
git tag [-a | -s | -u < keyid>] [-f] [-m | -F < file>]
< tagname> [< commit> | < object>]
git tag -d < tagname>…
git tag [-n[< num>]] -l [- -contains < commit>] [- -points-at < object>]
[- -column[=< options>] | - -no-column] [- -create-reflog] [- -sort=< key>]
[- -format=< format>] [- -[no-]merged [< commit>]] [< pattern>…]
git tag -v < tagname>…
共享和更新项目(Sharing and Updating Projects)
git fetch : 从另一个仓库下载对象和参数git fetch [< options>] [< repository> [< refspec>…]]
git fetch [< options>] < group>
git fetch - -multiple [< options>] [(< repository> | < group>)…]
git fetch - -all [< options>]
git pull : 从其他仓库或本地分支中获取并整合进当前仓库
git pull [options] [< repository> [< refspec>…]]
git push : 将当前提交的修改更新到远程绑定的仓库
git push [- -all | - -mirror | - -tags] [- -follow-tags] [- -atomic] [-n | - -dry-run] [- -receive-pack=< git-receive-pack>]
[- -repo=< repository>] [-f | - -force] [- -prune] [-v | - -verbose]
[-u | - -set-upstream]
[- -[no-]signed|- -sign=(true|false|if-asked)]
[- -force-with-lease[=< refname>[:< expect>]]]
[- -no-verify] [< repository> [< refspec>…]]
git remote : 管理远程仓库
git remote [-v | - -verbose]
git remote add [-t < branch>] [-m < master>] [-f] [- -[no-]tags] [- -mirror=< fetch|push>] < name> < url>
git remote rename < old> < new>
git remote remove < name>
git remote set-head < name> (-a | - -auto | -d | - -delete | < branch>)
git remote set-branches [- -add] < name> < branch>…
git remote get-url [- -push] [- -all] < name>
git remote set-url [- -push] < name> < newurl> [< oldurl>]
git remote set-url - -add [- -push] < name> < newurl>
git remote set-url - -delete [- -push] < name> < url>
git remote [-v | - -verbose] show [-n] < name>…
git remote prune [-n | - -dry-run] < name>…
git remote [-v | - -verbose] update [-p | - -prune] [(< group> | < remote>)…]
git submodule : 初始化,更新或检查子模块
参考
Git命令使用整理Git命令详解
Git常用命令
Git基本命令行操作
Git-Reference
相关文章推荐
- 嵌入式Linux之字符设备驱动
- Simple Java—Compiler and JVM(一)Java对象运行时的内存结构
- kylin实现(1)-----share公共组件(基础组件)
- 模块化
- Treap平衡树
- 阿里巴巴利润暴涨108%
- RPI的入门教程(树莓派)
- CentOs6.7环境下rpm包安装mysql5.7
- 每天吃多少才不会胖?食物和卡路里对照表
- POJ 2253 —— Frogger
- 年末总结——关于读书学习
- MacDown 编辑器 使用
- BZOJ-1206 虚拟内存 Hash+离散化+Priority_Queue
- Android NDK开发基础——配置及简单案例
- 《Learn You Some Erlang for Great Good!》的学习笔记(四)
- BZOJ-1206 虚拟内存 Hash+离散化+Priority_Queue
- 数据结构和算法学习
- OpenPyXL学习
- HUD1754 (完全二叉树)
- hdu 5615 Jam's math problem(判断是否能合并多项式)