将文件添加到Git版本库中

一、 创建一个测试文件(git_test_file)

[root@git git_test]# echo fuchao >git_test_file

二、 把测试文件添加到版本库的暂存区中

[root@git git_test]# git add git_test_file

三、 查看处于暂存区的文件

[root@git git_test]# git status

On branch master

Initial commit

Changes to be committed:

(use "git rm --cached <file>..." to unstage)

new file: git_test_file

[root@git git_test]#

四、讲文件添加到版本库

[root@git git_test]# git commit -m "Submission instructions" \

--author="fuchao 961769710@qq.com"
下面是命令输出:
[master (root-commit) 9cb4509] Submission instructions
Author: fuchao 961769710@qq.com
Committer: root <root@git.(none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

git config --global user.name "Your Name"
git config --global user.email you@example.com

If the identity used for this commit is wrong, you can fix it with:

git commit --amend --author='Your Name <you@example.com>'

1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 git_test_file
[root@git git_test]#

查看工作区的状态

[root@git git_test]# git status

On branch master

nothing to commit (working directory clean)

可以看到工作区现在是干净的了

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容