Git开发实战(一)之Git的安装配置与基本操做

1、Git的安装html

      1.Linuxgit

  • apt-get insatll git    ubuntu
  • yum install git         centos/redhat

      2.Mac OSshell

      xcode应该自带了ubuntu

      3.Windowsvim

      也有客户端(实际上就是windows上的命令行)git官网 git-scm.comwindows

      4.提示centos

  • 不要迷信图形化工具!
  • 好用的Git是没有图形化工具的!命令行是王道!特别是新手,不要偷懒!
  • 本《Git开发实战》系列博客是在Windows的git_shell中进行命令行操做的

2、Git的配置和基本操做xcode

      1.Git安装成功后,使用git命令,查看git的一些常见命令bash

aibin@XiaoAibin MINGW64 ~/Desktop
$ 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>]

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.

      2.能够经过git --version命令查看当前git的版本信息app

aibin@XiaoAibin MINGW64 ~/Desktop
$ git --version
git version 2.10.0.windows.1

      3.配置文件,包括全局配置和局部配置

     

      全局配置:

      (1)使用cat ~/.gitconfig命令就能够进入到git的home目录下并显示出git的全局配置信息

aibin@XiaoAibin MINGW64 ~/Desktop
$ cat ~/.gitconfig

      (2)使用vim ~/.gitconfig命令能够编辑git的全局配置信息文件

aibin@XiaoAibin MINGW64 ~/Desktop
$ vim ~/.gitconfig

      局部配置:

      (1)首先,我在桌面上使用mkdir命令建立一个目录test-git,而后用cd命令切换到这个目录下,而后使用ls -altrh查看这个目录下有什么文件,发现新建立的目录下,什么也没有!

aibin@XiaoAibin MINGW64 ~/Desktop
$ mkdir test_git

aibin@XiaoAibin MINGW64 ~/Desktop
$ cd test_git

aibin@XiaoAibin MINGW64 ~/Desktop/test_git
$ ls -altrh
total 28K
drwxr-xr-x 1 aibin 197609 0 10月 23 14:50 ../
drwxr-xr-x 1 aibin 197609 0 10月 23 14:50 ./

      (2)而后使用git init命令对test-git这个目录进行了git版本控制,而后会发现这个目录下会多出一个.git的目录

aibin@XiaoAibin MINGW64 ~/Desktop/test_git
$ git init .
Initialized empty Git repository in C:/Users/aibin/Desktop/test_git/.git/

aibin@XiaoAibin MINGW64 ~/Desktop/test_git (master)
$ ls -altrh
total 32K
drwxr-xr-x 1 aibin 197609 0 10月 23 14:50 ../
drwxr-xr-x 1 aibin 197609 0 10月 23 14:52 ./
drwxr-xr-x 1 aibin 197609 0 10月 23 14:52 .git/

       (3)接着使用vim .git/ 命令,咱们能够看到.git下面有好几个目录,如图所示:

     

      (4)咱们用上下键移动到config这个文件上,而后进入这个文件,咱们能够看到以下配置信息:

[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[user]
        name = kevinShaw
        email = aibinxiao@126.com

      (5)咱们能够直接在这个文件中修改配置信息,固然咱们也能够经过命令git config user.name kevin进行修改

aibin@XiaoAibin MINGW64 ~/Desktop/test_git (master)
$ git config user.name kevinShaw

 

本文为原创文章,若是对你有一点点的帮助,别忘了点赞哦!比心!如需转载,请注明出处,谢谢!

相关文章
相关标签/搜索