在本机上E:\myGit 下新增一个文件 test.txt ,此处不建议用windows自带的记事本,那玩意儿比较坑爹,可以用notepad++ 、sublime text之类的文本编辑软件,我个人喜欢sublime text。内容如下:
This is a git test file.
保存之后在此处打开Git Bash,输入git add 指令,将该文件加入工作区,如下:
$ git add test.txt
此时该文件处于系统中的工作区,类似于暂存区的地方,还不算保存在版本库里面,还需要提交git commit,才能保存到版本库里面,此时我们可以查看git 的状态,用指令git status查看:
$ git status
# On branch master
# Changes to be commit:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: test.txt
状态提示你有任务需要提交,好了,接下来你确定了自己增加的文件后就可以提交了。
$ git commit -m "add a test file"
[master (root-commit) ec14403] add a test file
1 file changed, 1 insertions(+)
create mode 100644 test.txt
再次git status 查看状态:
$ git status
# On branch master
nothing to commit,working directory clean
意思是当前没有需要提交的任务,工作区也很干净,没有文件,这样你就把自己的文件存入版本库了。