③. 初始化坏境配置 init
- ①. 在电脑的任意位置创建一个空目录(例如repo1)作为我们的本地Git仓库
- ②. 进入这个目录中,点击右键打开Git bash窗口
- ③. 执行命令git init
如果在当前目录中看到.git文件夹(此文件夹为隐藏文件夹)则说明Git仓库创建成功
④. 查看文件状态 status
- ①. git status 查看文件状态
- ②. 也可以使用git status –s 使输出信息更加简洁
Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/repo1 (master) $ vim a.txt Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/repo1 (master) $ vim a.txt Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/repo1 (master) $ git status On branch master No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) a.txt nothing added to commit but untracked files present (use "git add" to track) Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/repo1 (master) $ git status -s ?? a.txt
⑤. 添加到暂存区、撤回到工作目录 add|reset
①. git add 将未跟踪的文件加入暂存区(将新创建的文件加入暂存区后查看文件状态)
②. git add .(.代表所有新增、修改)
③. git add -A( -A 新增、修改、删除)推荐使用
④. git reset 将暂存区的文件取消暂存(将文件取消暂存后查看文件状态)
$ git add a.txt warning: LF will be replaced by CRLF in a.txt. The file will have its original line endings in your working directory Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/repo1 (master) $ git status On branch master No commits yet Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: a.txt Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/repo1 (master) $ git reset a.txt Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/repo1 (master) $ git status On branch master No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) a.txt nothing added to commit but untracked files present (use "git add" to track) Administrator@SD-20191128LXMQ MINGW64 /d/gitRepos/repo1 (master)