Git(4)——把文件添加并提交到版本库

来源:互联网 发布:什么是域名根目录 编辑:程序博客网 时间:2024/05/22 03:28

把文件添加并提交到版本库


千万不要使用Windows自带的记事本编辑任何文本文件,下载notepad++进行编辑,仅限于windows。

编写一个readme.txt文件,内容如下

Git is a version control system.Git is free software.

一定要放到learngit目录下(子目录也行),因为这是一个Git仓库,放到其他地方Git再厉害也找不到这个文件。

1. 用命令git add把文件添加到仓库

$ git add readme.txt

2. 用命令git commit把文件提交到仓库

$ git commit -m "wrote a readme file"[master (root-commit) cb926e7] wrote a readme file 1 file changed, 2 insertions(+) create mode 100644 readme.txt

git commit命令,-m后面输入的是本次提交的说明,可以输入任意内容,当然最好是有意义的,这样你就能从历史记录里方便地找到改动记录。

commit可以一次提交很多文件,所以你可以多次add不同的文件

3. 用命令git status查看版本库的状态

$ git statusOn branch masternothing to commit, working tree clean
0 0
原创粉丝点击