shj@MSI MINGW64 /d/code_lib/git-demo $ git init Initialized empty Git repository in D:/code_lib/git-demo/.git/ shj@MSI MINGW64 /d/code_lib/git-demo (master) $ ll -a total 5 drwxr-xr-x 1 shj 197121 0 Jul 31 17:04 ./ drwxr-xr-x 1 shj 197121 0 Jul 31 17:02 ../ drwxr-xr-x 1 shj 197121 0 Jul 31 17:04 .git/ -rw-r--r-- 1 shj 197121 248 Jul 31 17:03 hello.txt shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git status On branch master No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) hello.txt nothing added to commit but untracked files present (use "git add" to t rack) shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git add hello.txt shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git status On branch master No commits yet Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: hello.txt shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git commit -m "first commit" hello.txt [master (root-commit) f9be8a9] first commit 1 file changed, 10 insertions(+) create mode 100644 hello.txt shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git status On branch master nothing to commit, working tree clean shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git reflog f9be8a9 (HEAD -> master) HEAD@{0}: commit (initial): first commit shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git log\ > ^C shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git log commit f9be8a93d5be82fb21941ff66ac23a9bd5ce9896 (HEAD -> master) Author: shenhj <[email protected]> Date: Mon Jul 31 17:06:08 2023 +0800 first commit shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: hello.txt no changes added to commit (use "git add" and/or "git commit -a") shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git add hello.txt shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git status On branch master Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: hello.txt shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git commit -m "second commit" hello.txt [master e61dab7] second commit 1 file changed, 1 insertion(+), 1 deletion(-) shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git reflog e61dab7 (HEAD -> master) HEAD@{0}: commit: second commit f9be8a9 HEAD@{1}: commit (initial): first commit shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: hello.txt no changes added to commit (use "git add" and/or "git commit -a") shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git add hello.txt shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git commit -m "third commit" hello.txt [master bfde9da] third commit 1 file changed, 1 insertion(+), 1 deletion(-) shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git reflog bfde9da (HEAD -> master) HEAD@{0}: commit: third commit e61dab7 HEAD@{1}: commit: second commit f9be8a9 HEAD@{2}: commit (initial): first commit shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git status On branch master nothing to commit, working tree clean shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git reset --hard e61dab7 HEAD is now at e61dab7 second commit shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git reflog e61dab7 (HEAD -> master) HEAD@{0}: reset: moving to e61dab7 bfde9da HEAD@{1}: commit: third commit e61dab7 (HEAD -> master) HEAD@{2}: commit: second commit f9be8a9 HEAD@{3}: commit (initial): first commit shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git reset --hard f9be8a9 HEAD is now at f9be8a9 first commit shj@MSI MINGW64 /d/code_lib/git-demo (master) $ git reflog f9be8a9 (HEAD -> master) HEAD@{0}: reset: moving to f9be8a9 e61dab7 HEAD@{1}: reset: moving to e61dab7 bfde9da HEAD@{2}: commit: third commit e61dab7 HEAD@{3}: commit: second commit f9be8a9 (HEAD -> master) HEAD@{4}: commit (initial): first commit
shj@MSI MINGW64 /d/code_lib/git-demo (master)
1.命令解析
git init :初始化,生成 .git文件
git status:查看状态
git add <文件名>:将文件从工作区添加到暂存区
git commit -m "first commit" <文件名>:将文件从暂存区添加到本地库
git reflog:查看提交日志信息
git log:查看详细提交日志信息
git reset --hard <版本号>:恢复历史版本
2.版本管理原理
指针
3.内存管理
工作区(电脑中存放代码)----》暂存区----》本地库----》远程库
标签:git,demo,穿梭,code,master,版本,commit,shj From: https://www.cnblogs.com/cxacswx/p/17593994.html