Git

1.安装

  去官网下载,双击安装,只需下一步就安装完成了!

2.命令

#命令集合
git init  #--------------------------------------初始化
git status #*************************************查看状态
git add a.text #---------------------------------添加到本地临时库
git commit -m "first commit" a.text #************提交到本地库形成版本信息
git reflog #-------------------------------------查看日志
git lof #****************************************查看详细日志
#=======================================================================
#=======================================================================
git branch -v #----------------------------------查看分支
git branch banben1 #*****************************创建分支 版本1
git checkout banben1 #---------------------------切换分支
git merge banben1  #………………………………………………………………………………合并分支

3.使用

1.设置签名

安装完毕后桌面右键,也可以在任何目录下打开

GitGit

初次使用需要为本机设置账户名和邮箱---注意!这个和GitHub账号没有任何关系!!!这个只是用来标识谁的主机

#设置用户签名
tears@DESKTOP-J6IQL9F MINGW64 /c/Code $ git config --global user.name daluobo #账户 tears@DESKTOP-J6IQL9F MINGW64 /c/Code $ git config --global user.email daluobo@dlb # 邮箱虚假邮箱,这个邮箱随意写

是否安装好?C:\Users\tears\.gitconfig

到这个目录下查看这个文件中是否有配置好的账户和邮箱

2.初始化目录

打开准备工作的目录 右键打开git窗口

#git的本地库初始化,生成文件是隐藏的
git init 

3.查看状态

git status
$ git status  #查看状态命令
On branch master   #当前主分支 安装时候git默认分支名就是master

No commits yet    #没有提交过,空库
#无需提交(创建/复制文件并使用“git add”来跟踪)
nothing to commit (create/copy files and use "git add" to track) 
vim a.text  #创建新文件  yy是复制  p是粘贴   Linux命令基本通用

$ git status
On branch master
No commits yet
Untracked files: #git没有追踪过这个文件
  (use "git add <file>..." to include in what will be committed)
        a.text                                      #提示需要追加得到暂存区
nothing added to commit but untracked files present (use "git add" to track)

4.添加到本地库

#执行 git add a.text
$ git add a.text
warning: LF will be replaced by CRLF in a.text.  #出现警告不用管,来自FBI的警告
The file will have its original line endings in your working directoryxxxxxxxxxx4 1$ git add a.text2warning: LF will be replaced by CRLF in a.text.3The file will have its original line endings in your working directory4git add a.text
#再次查看状态,发现
$ git status
On branch master
No commits yet
Changes to be committed:
#提示用这个命令可以删掉文件,只是删掉了暂存区,工作区还有的  git rm --cached a.text
  (use "git rm --cached <file>..." to unstage) 
        new file:   a.text    #这个地方绿了! 提交到了暂存库

5.提交本地库

提交后形成 版本信息

#-m后面是本次提交的信息,比如:更新了登录验证
$ git commit -m "first commit" a.text
warning: LF will be replaced by CRLF in a.text.
The file will have its original line endings in your working directory
[master (root-commit) e513bd0] first commit
 1 file changed, 2 insertions(+)
 create mode 100644 a.text
 #查看状态
 $ git status
On branch master
nothing to commit, working tree clean  #没有东西需要提交

6.查看日志信息

$ git reflog  #--查看日志
#版本号   指针 指向 master                            提交信息
e513bd0 (HEAD -> master) HEAD@{0}: commit (initial): first commit
#-----查看详细日志命令
$ git log
#完整版的 版本号
commit e513bd01920c011289260813ba30e01a8c598622 (HEAD -> master)
Author: daluobo <daluobo@dlb>        #谁提交了命令
Date:   Sat Dec 11 14:57:11 2021 +0800 #时间

    first commit

 

上一篇:Calico


下一篇:6、shell-函数