本地倉(cāng)庫(kù)常用命令
- git:查看系統(tǒng)有沒(méi)有安裝Git
- 設(shè)置全局屬性夸浅,用戶名和郵箱
C:\Users\98100>git config --global user.name "AithusaDou"
C:\Users\98100>git config --global user.email "981006610@qq.com"
- git init:創(chuàng)建版本庫(kù)
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:將文件添加到臨時(shí)區(qū)
D:\learngit>git add hello.txt
- git status:查看當(dāng)前的Git倉(cāng)庫(kù)狀態(tài)
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:查看從近到遠(yuǎn)的提交日志
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:查看文件修改內(nèi)容
git log --pretty=online:簡(jiǎn)略日志
git reflog:查看命令歷史
git reset --hard HEAD:退回到上一版本