你的位置:首页 > ASP.net教程

[ASP.net教程]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 directory12   init    Create an empty Git repository or reinitialize an existing one13 14 work on the current change (see also: git help everyday)15   add    Add file contents to the index16  mv     Move or rename a file, a directory, or a symlink17   reset   Reset current HEAD to the specified state18  rm     Remove files from the working tree and from the index19 20 examine the history and state (see also: git help revisions)21  bisect   Use binary search to find the commit that introduced a bug22  grep    Print lines matching a pattern23   log    Show commit logs24   show    Show various types of objects25  status   Show the working tree status26 27 grow, mark and tweak your common history28  branch   List, create, or delete branches29  checkout  Switch branches or restore working tree files30   commit   Record changes to the repository31  diff    Show changes between commits, commit and working tree, etc32  merge   Join two or more development histories together33  rebase   Reapply commits on top of another base tip34  tag    Create, list, delete or verify a tag object signed with GPG35 36 collaborate (see also: git help workflows)37   fetch   Download objects and refs from another repository38   pull    Fetch from and integrate with another repository or a local branch39 40   push    Update remote refs along with associated objects41 42 'git help -a' and 'git help -g' list available subcommands and some43 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 ~\public2 cd ~\public3 echo 'hello git' > index.html4 git init

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

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

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

 

  1.2 将文件添加进版本库

   

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

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

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

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

  

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

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

 

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