关于git和github的介绍,我这边不多说。

使用在windows下使用git,需要配置环境变量,也可以使用git自带的终端工具。,打开git bash

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的终端相识,首先需要进行初始化,也就是配置个人信息:

使用git help可以查看git相关命令,也可以通过git help command指定命令查询。

$ 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"可以添加用户名和邮箱,

使用 git config --unset --global user.name 可以取消用户名配置,

使用 git config --list 查看所有可用的配置信息。

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@.com
filter.lfs.clean=git-lfs clean %f
filter.lfs.smudge=git-lfs smudge %f
filter.lfs.required=true

git config

git区分工作区和版本库

对于项目根目录github_test目录来说,这就是工作区。

使用 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里的快捷方式了,这个需要理清。

git config配置,工作区和版本库联系。的更多相关文章

  1. git 工作区与版本库

    git 工作区.版本库 在我们使用git的时候,我们脑海中一定要有一个关于git的框架,如下图: 我们先对git的工作区.暂存区.本地仓库做一个基本的解释 工作区: 就是我们电脑中代码的下载目录 版本 ...

  2. Git版本控制工具(一)----git的安装及创建版本库

    ​[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/ ...

  3. Git的使用(3) —— 远程版本库的操作(GitHub)

    1. 配置SSH (1) GitHub 登陆GitHub后,点击右上角头像,选择 Setting . 在左面栏目中选择"SSH and GPG keys". 打开生成的SSH公钥文 ...

  4. Git的使用(2) —— 本地版本库的操作

    1. 向本地版本库中添加文件 注意:.git文件夹是本地版本库,包含.git文件夹的目录叫工作目录,要往本地版本库中添加文件,就必须将文件放在工作目录中. (1) 把文件添加到工作目录中. (2) 右 ...

  5. Git 学习(二)版本库创建

    Git 版本库创建 什么是版本库(repository)? 可理解为文件仓库.由Git管理每个文件的新增.修改及删除,但这个仓库可以追溯历史.可还原至任意历史节点. 版本库创建 创建一个版本库非常简单 ...

  6. Git使用(二)版本库创建及文件修改

    一.创建版本库 1.安装完成后,在开始菜单里找到“Git”->“Git Bash”,蹦出一个类似命令行窗口的东西,就说明Git安装成功! 安装完成后,还需要最后一步设置,在命令行输入: $ gi ...

  7. Git 的安装和创建版本库 。

    Git 的优点就不再多说了 .直接进入正题吧 . 安装Git 首先可以尝试输入 Git 看看有没有反映 . $ git The program 'git' is currently not insta ...

  8. git config 配置

    1. git config简介 我们知道config是配置的意思,那么git config命令就是对git进行一些配置.而配置一般都是写在配置文件里面,那么git的配置文件在哪里呢?互动一下,先问下大 ...

  9. Git学习笔记02-创建版本库

    版本库就是一个目录,这个目录里面的所有文件都会被Git管理,每个文件的修改,删除都能追踪.以便在某个时刻追踪历史记录,或者还原 路径切换,查看文件命令和linux差不多,cd 文件路径  ls查看路径 ...

随机推荐

  1. java 并发——synchronized

    java 并发--synchronized 介绍 在平常我们开发的过程中可能会遇到线程安全性的问题,为了保证线程之间操作数据的正确性,我们第一想到的可能就是使用 synchronized 并且 syn ...

  2. linux替换rm命令,防止误删

    1. 在/home/username/ 目录下新建一个目录,命名为:.trash 2.. 在/home/username/tools/目录下,新建一个shell文件,命名为: remove.sh #! ...

  3. UVA11054_Wine trading in Gergovia

    大致题意: 直线上有n个村庄,要么买酒要么卖酒,运酒到隔壁村庄需要这个酒的权值个劳动力 问你至少需要多少劳动力 题目保证了所有权值和为0!!!!!!!!!!!!这个意义重大,表示这是一个封闭的群体 这 ...

  4. git 关于commit命令的修改

    1 修改最后一次提交的信息 git commit --amend 2 对于历史提交 git rebase -i HEAD~5 没毛病,

  5. proc伪文件系统 - 加载一个进程

    内核模块的编译方法及注意事项 Ubuntu内核(2.6.32) 2.6内核中,模块的编译需要配置过的内核源码:编译.链接后生成的内核模块后缀为.ko:编译过程首先会到内核源码目录下读取顶层的Makef ...

  6. 我学习的自定义ASP.NET分页控件

    public class MyPagecontroll { public int TotalCount { get; set; }//数据的总条数 public int PageSize { get; ...

  7. 自定义vant ui steps组件效果实现

    记录个问题,当作笔记吧:因为vue项目的移动端vant ui 的step组件跟ui设计图有差别,研究了半天还是没法使用step组件,只能手动设置一个 先上效果图和代码: (1)HTML部分 <d ...

  8. 灯泡编程题-java

    现在有100个灯泡,每个灯泡都是关着的,灯泡排序为1~100,接着将2的倍数的灯泡开关按一下,然后将3的倍数的灯泡开关按一下……直到将N的倍数的灯泡开关按一下,最后统计灯泡亮着的数目. 算法思路: 1 ...

  9. SSD网络结构

    SSD算法,其英文全名是Single Shot MultiBox Detector. SSD的网络结构流程如下图所示:SSD总共11个block,相比较于之前的VGG16,改变了第5个block的第4 ...

  10. 深入理解Magento-第九章-修改、扩展、重写Magento代码

    (博主提示:本章应该不是原作者的第九章,仅作补充和参考) 作为一个开发者的你,肯定要修改Magento代码去适应你的业务需求,但是在很多时候我们不希望修改Magento的核心代码,这里有很多原因,例如 ...