本地仓库常用命令
- git:查看系统有没有安装Git
- 设置全局属性,用户名和邮箱
C:\Users\98100>git config --global user.name "AithusaDou"
C:\Users\98100>git config --global user.email "981006610@qq.com"
- git init:创建版本库
C:\Users\98100>d:
D:\>mkdir learngit
D:\>cd learngit
D:\learngit>git init
Initialized empty Git repository in D:/learngit/.git/
- git add hello.txt:将文件添加到临时区
D:\learngit>git add hello.txt
- git status:查看当前的Git仓库状态
D:\learngit>git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: hello.txt
- git commit -m “create hello.txt file”:把文件提交
D:\learngit>git commit -m "create hello.txt file"
[master (root-commit) d096a64] create hello.txt file
1 file changed, 1 insertion(+)
create mode 100644 hello.txt
- git log:查看从近到远的提交日志
D:\learngit>git log
commit 6757e227e580a6e6becf59b7c1a8b021e0195a71 (HEAD -> master)
Author: AithusaDou <981006610@qq.com>
Date: Mon Sep 17 08:56:31 2018 +0800
add a new line
commit d096a6428f66725637688b4d9b81f45be5ea2a64
Author: AithusaDou <981006610@qq.com>
Date: Mon Sep 17 08:54:37 2018 +0800
create hello.txt file
- git reset --hard commit_id:退回到某一版本
D:\learngit>git reset --hard d096a
HEAD is now at d096a64 create hello.txt file
-
git diff:查看文件修改内容
-
git log --pretty=online:简略日志
-
git reflog:查看命令历史
-
git reset --hard HEAD:退回到上一版本
网友评论