Git 笔记, git commit

一, git commit 和 git commit -a

首先我们来看一下, git 文件的三种状态:

在Git 内都只有三种状态:

已提交(commited): 表示该文件已经被安全地保存在本地数据库中;    

已修改(modified):表示修改了某个文件,但还没有提交保存; modified:   .gitignore

已暂存(staged):表示把已修改的文件放在下次提交时要保存的清单中.    new file: new_file_test.txt


mrhero@MrsHero:~/mrhero/bitbucket_pro/fun_excel$ git status 
On branch master
Your branch is up-to-date with 'origin/master'.


Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)


<span style="white-space:pre">	</span><span style="background-color: rgb(102, 102, 0);">new file:   new_file_test.txt</span>


Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)


<span style="white-space:pre">	</span><span style="background-color: rgb(0, 102, 0);">modified:   .gitignore</span>


Untracked files:
  (use "git add <file>..." to include in what will be committed)


<span style="white-space:pre">	</span><span style="background-color: rgb(0, 102, 0);">new_file_test2.txt</span>

git commit 提交的是暂存区里面的内容,也就是  Changes to be committed  中的文件。

<span style="background-color: rgb(245, 245, 245);">mrhero@MrsHero:~/mrhero/bitbucket_pro/fun_excel$ </span><span style="background-color: rgb(153, 102, 51);">git commit -m "test git commit"[master d9a2721] test git commit</span><span style="background-color: rgb(245, 245, 245);">
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 new_file_test2.txt
mrhero@MrsHero:~/mrhero/bitbucket_pro/fun_excel$ </span><span style="background-color: rgb(153, 102, 51);">git status</span><span style="background-color: rgb(245, 245, 245);"> 
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	</span><span style="background-color: rgb(0, 153, 0);">modified:   .gitignore</span><span style="background-color: rgb(245, 245, 245);">

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	</span><span style="background-color: rgb(0, 102, 0);">new_file_test.txt</span><span style="background-color: rgb(245, 245, 245);">

no changes added to commit (use "git add" and/or "git commit -a")
</span>

git commit -a 除了将暂存区里的文件提交外,还提交 Changes not staged fro commit 中的文件。

mrhero@MrsHero:~/mrhero/bitbucket_pro/fun_excel$ git commit -a -m "test git commit -a"
[master c0fa5a4] test git commit -a
 2 files changed, 1 insertion(+), 1 deletion(-)
 create mode 100644 new_file_test2.txt
mrhero@MrsHero:~/mrhero/bitbucket_pro/fun_excel$ git status 
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	new_file_test.txt

nothing added to commit but untracked files present (use "git add" to track)




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值