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

 

本文爲原創文章,若是對你有一點點的幫助,別忘了點贊哦!比心!如需轉載,請註明出處,謝謝!

相關文章
相關標籤/搜索