【2.1】Git的基本使用

导读:本篇文章讲解 【2.1】Git的基本使用,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

1、修改之前已经提交成功了的demo.c文件,使用git status命令进行查看项目状态。

Colin.Tan@Noir MINGW64 /f/code/demo (master)
$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   demo.c
no changes added to commit (use "git add" and/or "git commit -a")

2、如上所述:demo.c已经被修改,为了能够更清晰的看见文件内容上的修改需使用git diif命令。

Colin.Tan@Noir MINGW64 /f/code/demo (master)
$ git diff
diff --git a/demo.c b/demo.c
index 4de8d39..b5da506 100644
--- a/demo.c
+++ b/demo.c
@@ -1,7 +1,8 @@
-#include<stdio.h>
+#include<iostream>
+using namespace std;
 int main(void)
 {
-       printf("hello world!\n");
+       cout << "Hello World!" << endl;
        return 0;
 }
其中-红色的表示修改前的,+绿色的表示修改后的。

3、

1)使用git add进行提交文件

2)在使用git commit之前先使用git status查看项目的状态

【2.1】Git的基本使用

3)上图中的demo.c变绿了,将要提交的修改的是demo.c,git commit提交。

Colin.Tan@Noir MINGW64 /f/code/demo (master)
$ git commit -m "change the c to c++"
[master bf38574] change the c to c++
 1 file changed, 3 insertions(+), 2 deletions(-)

4)提交之后再次查看项目状态

【2.1】Git的基本使用

工作目录clean,没有修改需要提交。

 

小贴士:记得随时查看项目的状态 git status

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/117029.html

(0)
seven_的头像seven_bm

相关推荐

发表回复

登录后才能评论
极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!