阿宁的linux学习----Git工作区和暂存区

这是我学习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
无文件要提交,干净的工作区
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值