1.安装Git(通过官网或影像);
2.基本信息设置:
git config --global user.name "ywangela"
git config --global user.email "luckygirl666123@163.com"
global参数:说明我这台机器上所有的Git仓库都会使用这个配置,或者对某个仓库指定不同的用户名和Email地址,也是可以的。
3.创建版本库(仓库)
(1)创建空目录;
mkdir learngit(windows中,目录名切勿用中文名)
cd learngit
pwd
(2)将此目录变成Git可管理的仓库,即初始化仓库。
git init
此时,当前目录下会多了一个.git的隐藏文件
4.上手编写文件
(1)编写readme.txt(touch readme.txt),其内容如下(vim)
this is the first git version.
(2)使用git add将文件添加到仓库中,可多次使用
git add readme.txt
warning: LF will be replaced by CRLF in readme.txt.
(3)使用git commit将文件提交到仓库中
git commit -m "write the first file."
-m后写的是本次提交的说明
(4)修改readme文件,修改后为
this is the second git version.
(5)使用git status查看仓库当前状态
On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: readme.txt no changes added to commit (use "git add" and/or "git commit -a")
(6)使用git diff xxx 参看具体的修改内容
(7)重复第(1)(2)步,将第二次描述改为"write the second file."
(8)再次使用git status查看仓库当前状态
nothing to commit,working tree clean(git告诉我们当前没有需要提价的修改,并且,工作目录是干净的)
本文基于廖雪峰老师的git教程整理,附上教程地址:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000
git文档地址:https://git-scm.com/doc
今天是新的一天,我要努力学好技术 :)