git config配置,工做区和版本库联系。

    关于git和github的介绍,我这边很少说。html

使用在windows下使用git,须要配置环境变量,也能够使用git自带的终端工具。,打开git bashpython

laoni@DESKTOP-TPPLHIB MINGW64 ~ (master)
$ cd c:/laoni

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni
$ dir
AutomatedMonitor  bak  Mr.blue  PycharmProjects

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni
$ cd PycharmProjects/

界面和linux的终端相识,首先须要进行初始化,也就是配置我的信息:linux

使用git help能够查看git相关命令,也能够经过git help command指定命令查询。git

$ 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.
git help

使用git config --global user.name "XXX" 和git config --global user.email "XXX@XX.com"能够添加用户名和邮箱,github

使用 git config --unset --global user.name 能够取消用户名配置,windows

使用 git config --list 查看全部可用的配置信息。bash

 
laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test
$ git config --global user.name 'LaoNiNi'

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test
$ git config --global user.email "laonivv@163.com"

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test
$ git config --unset --global user.name

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test
$ git config --list
core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=F:/pythonfile/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.required=true
filter.lfs.process=git-lfs filter-process
credential.helper=manager
user.email=laonivv@163.com
filter.lfs.clean=git-lfs clean %f
filter.lfs.smudge=git-lfs smudge %f
filter.lfs.required=true
git config

 git区分工做区和版本库app

对于项目根目录github_test目录来讲,这就是工做区。ide

使用 git init 命令进行初始化,以前的config配置,须要初始化才能生效,config配置信息存在.git/config文件工具

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test
$ git init
Initialized empty Git repository in C:/laoni/PycharmProjects/github_test/.git/

PS:若是对git不熟悉的话,建议不要对。git目录下的文件进行修改。

使用git status查看当前git状态,Untracked files(未监视的文件,未被跟踪文件)也就是没有存到暂存区(上面截图的版本库下的index部分)的文件,使用git add index.html 把文件添加到暂存区。

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test (master)
$ git status
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        index.html

nothing added to commit but untracked files present (use "git add" to track)

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test (master)

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test (master)
$ git add index.html

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test (master)
$ git status
  On branch master

  Initial commit

Changes to be committed:
     (use "git rm --cached <file>..." to unstage)

          new file: index.html

 

把index.html文件添加到暂存区后,须要把文件从暂存区添加到branch master分支上,通常一个项目会有个主分支(通常叫master),使用git commit提交,会提示说明下此次的提交注释,再用git status查看,提示在当前主分支,没有须要commit的文件,工做区很干净。

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test (master)
$ git commit
[master (root-commit) 04c94a8] 添加一个文件index.html
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 index.html

laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/github_test (master)
$ git status
On branch master
nothing to commit, working tree clean

实际上无论是暂存区仍是分支上的文件,都存储在objects里面,暂存区和分支上的文件只是一个指向,目录树,有点像windows里的快捷方式了,这个须要理清。

相关文章
相关标签/搜索