git本地仓库基本操作

1.git:查看系统有没有安装Git

  • 安装完成后,在开始菜单里找到“Git”->“Git Bash”,蹦出一个类似命令行窗口的东西,就说明Git安装成功!

2.设置全局属性,用户名和邮箱

$git config --global user.name "qiansao"

$git config --global user.email "[email protected]"

3. git init:创建版本库

$git init
Initialized empty Git repository in D:/learngit/.git/

4. git add hello.txt:将文件添加到临时区

git add hello.txt

5.git commit -m “create hello.txt file”:把文件提交到仓库

$git commit -m "creat hello.txt file"
[master (root-commit) f5480f5] creat hello.txt file
 1 file changed, 1 insertion(+)
 create mode 100644 hello.txt

6.git status:查看当前的Git仓库状态

$git status
On branch master
nothing to commit, working tree clean

7.git log:查看从近到远的提交日志

git log
commit 83018ce8b3dc082cd5e5a25c42351afa1e792c26 (HEAD -> master)
Author: qiansao <[email protected]>
Date:   Mon Sep 17 08:56:52 2018 +0800

    add a new line

commit f5480f520dad0a7e084cfe8a93e8782876805d00
Author: qiansao <[email protected]>
Date:   Mon Sep 17 08:54:44 2018 +0800

    creat hello.txt file

8.git reset --hard commit_id:退回到某一版本

$git reset --hard f5480
HEAD is now at f5480f5 creat hello.txt file

9.git diff:查看文件修改内容

10.git log --pretty=online:简略日志

11.git reflog:查看命令历史

83018ce (HEAD -> master) HEAD@{0}: reset: moving to 83018ce
f5480f5 HEAD@{1}: reset: moving to f5480f5
83018ce (HEAD -> master) HEAD@{2}: reset: moving to 83018
f5480f5 HEAD@{3}: reset: moving to f5480f520dad0a7e084cfe8a93e8782876805d00
83018ce (HEAD -> master) HEAD@{4}: commit: add a new line
f5480f5 HEAD@{5}: commit (initial): creat hello.txt file

12git reset --hard HEAD:退回到上一版本

你可能感兴趣的:(git本地仓库基本操作)