- 首先在你的仓库目录下新建一个文件,如下
huanyu@ubuntu:~/git$ vim readme.txt
Hello git
I know you are powerful.
- 第一步,用命令git add告诉Git,把文件添加到仓库
huanyu@ubuntu:~/git$ git add readme.txt
没有消息,说明添加成功。
- 第二步,用命令git commit告诉Git,把文件提交到仓库
huanyu@ubuntu:~/git$ git commit -m "This is a readme file"
[master (root-commit) 03303c4] This is a readme file
1 file changed, 2 insertions(+)
create mode 100644 readme.txt
简单解释一下git commit命令,-m后面输入的是本次提交的说明,要求一定要填写,方便以后查看记录。
git commit命令执行成功后会告诉你,1 file changed:1个文件被改动(我们新添加的readme.txt文件);2 insertions:插入了两行内容(readme.txt有两行内容)。
commit可以一次提交很多文件,所以你可以多次add不同的文件,比如:
$ git add file1.txt
$ git add file2.txt file3.txt
$ git commit -m "add 3 files."
网友评论