nothing to commit (create/copy files and use "git add" to track) #空仓库会显示上面的状况 #之后,可以用Linux或者Vscode创建一个文件,这里用Linux $ echo"ss" >file1.txt #此时再次查看状态,会发现变化 On branch master
No commits yet
Untracked files: (use "git add <file>..." to include in what will be committed) file1.txt
nothing added to commit but untracked files present (use "git add" to track) #之后使用添加命令,将文件放到暂存区中 $ git add file1.txt On branch master
No commits yet
Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: file1.txt #会发现,文件的状态再次被改变,表示该文件已经被添加到了暂存区域中 #在括号中的那一栏表示取消缓存 #之后,尝试将文件提交到仓库之中 $ git commit -m "ss" [master (root-commit) e3c2751] ss 1 file changed, 1 insertion(+) create mode 100644 file1.txt #显示以上信息,此时再来查看仓库的状态 $ git status On branch master nothing to commit, working tree clean #file已经不见了,已经到仓库里面了 #之后可以使用git log 查看仓库提交信息 $ git log commit e3c2751597d4b423fa23c338814725974282b6c8 (HEAD -> master) Author: huangjinhong <3392591652@qq.com> Date: Sun Dec 24 19:38:00 2023 +0800
ss #log后面可以加一些东西,来查看简洁的提交记录 $ git log --oneline e3c2751 (HEAD -> master) ss