这是我学习linux的过程,每天都会更新所学习的知识总结,每个例子都是我自己的亲手实践的,作为新人的我希望各位大佬提出宝贵的意见!!
前面讲了我们把文件往Git版本库里添加的时候,是分两步执行的:
第一步是用git add
把文件添加进去,实际上就是把文件修改添加到暂存区;
第二步是用git commit
提交更改,实际上就是把暂存区的所有内容提交到当前分支。
因为我们创建Git版本库时,Git自动为我们创建了唯一一个master
分支,所以,现在,git commit
就是往master
分支上提交更改。
你可以简单理解为,需要提交的文件修改通通放到暂存区,然后,一次性提交暂存区的所有修改。
下面我们就实验一下
[root@localhost reposiitory]# vim learn.txt
The future is scary but you can’t just run to the past cause it’s familiar apple.
Success is the ability to go from one failure to another with no loss of enthusiasm GPL.
Git has a mutable index called stage.
[root@localhost reposiitory]# git status
# 位于分支 master
# 尚未暂存以备提交的变更:
# (使用 "git add <file>..." 更新要提交的内容)
# (使用 "git checkout -- <file>..." 丢弃工作区的改动)
#
# 修改: learn.txt
#
修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
[root@localhost reposiitory]# git add learn.txt
[root@localhost reposiitory]# git status
# 位于分支 master
# 要提交的变更:
# (使用 "git reset HEAD <file>..." 撤出暂存区)
#
# 修改: learn.txt
[root@localhost reposiitory]# git commit -m 'newwoek'
[master f8386ce] newwoek
git commit --amend --reset-author
1 file changed, 1 insertion(+)
[root@localhost reposiitory]# git status
# 位于分支 master
无文件要提交,干净的工作区