现在git的使用,越来越普遍,逐渐的替代svn。git某些指令,因为在项目中不是经常使用,所以在用到的时候,又怕由于用错而导致提交或修改错误,所以,日常工作中,建议一定要提前掌握好,并对git做全面的学习,一防需要用的时候不会感觉到生疏。针对git的使用教程,网上特别的多,五花百门,在这里,我推荐的是,通过实战的操作,再结合git的指令,做一个全方面的体验。
当安装完git之后,你的右键会多了一个git bash的选项,建议初学者先使用git bash,熟悉每一条指令,等熟了之后,再去使用图形化的东西。
首先,通过的输入git --help,查询相关的帮助,我们会得到下列几个信息,通过这些信息,开始我们的学习之旅吧!
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>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
checkout Switch branches or restore working tree files
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.