GIT笔记命令行(1)

Git简单易用,只要输入git就可以列出他的所有参数

 1 C:\Users\spu>git
 2 usage: git [--version] [--help] [-C <path>] [-c name=value]
 3            [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
 4            [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
 5            [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
 6            <command> [<args>]
 7 
 8 These are common Git commands used in various situations:
 9 
10 start a working area (see also: git help tutorial)
11    clone      Clone a repository into a new directory
12    init       Create an empty Git repository or reinitialize an existing one
13 
14 work on the current change (see also: git help everyday)
15    add        Add file contents to the index
16    mv         Move or rename a file, a directory, or a symlink
17    reset      Reset current HEAD to the specified state
18    rm         Remove files from the working tree and from the index
19 
20 examine the history and state (see also: git help revisions)
21    bisect     Use binary search to find the commit that introduced a bug
22    grep       Print lines matching a pattern
23    log        Show commit logs
24    show       Show various types of objects
25    status     Show the working tree status
26 
27 grow, mark and tweak your common history
28    branch     List, create, or delete branches
29    checkout   Switch branches or restore working tree files
30    commit     Record changes to the repository
31    diff       Show changes between commits, commit and working tree, etc
32    merge      Join two or more development histories together
33    rebase     Reapply commits on top of another base tip
34    tag        Create, list, delete or verify a tag object signed with GPG
35 
36 collaborate (see also: git help workflows)
37    fetch      Download objects and refs from another repository
38    pull       Fetch from and integrate with another repository or a local branch
39 
40    push       Update remote refs along with associated objects
41 
42 'git help -a' and 'git help -g' list available subcommands and some
43 concept guides. See 'git help <command>' or 'git help <concept>'
44 to read about a specific subcommand or concept.
View Code

git命令可以分为短和长选项。例如:

git commit  -m "hello git"

git commit --message="hello git"

以上两条命令式等价的

 

1.Git入门

有两种简历git版本库的技术。可以从头开始创建,用现有的内容填充它,或者可以clone一个已有的版本库,从一个空的版本库比较简单,所有从空的版本库开始吧。

 

  1.1 创建一个初始版本库

  

1 mkdir ~\public
2 cd ~\public
3 echo 'hello git' > index.html
4 git init

  git init将public目录转化为了git版本库。

  git不关心你是从一个空白的目录还是一个装满目录的文件开始的。在这两种情况下将目录转换为GIT版本库是完全一样的。

  为了显示目录是一个git版本库。git init创建了一个隐藏的.git目录。git将所有修订信息都放在这唯一的顶层.git目录中。

 

  1.2 将文件添加进版本库

   

1 git add index.html
2 git commit -m 'init'
3 git status

  如果目录中有很多文件,可以用git add . 来添加进版本库。

  git将add、remove和commit分开,以避免频繁的变化。

  add仅仅只是把改变暂存在了本地。commit才是上传了改变。

  

  在add后,如果运行git status 可以查看git下一次将会把index.html上传给版本库

  除了原数据以外,git每次提交的时候,还会包括一些元数据,类似日志信息和作出本次变更的作者。

 

  如果仅仅只是运行git commit ,系统会调用设定好的编辑器来让你编辑

  

  

posted @ 2016-11-14 10:57  也许小念旧  阅读(243)  评论(0编辑  收藏  举报