使用git命令提交代码

命令(删除文件时)
  • 1、git status/查看代码的修改状态
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        deleted:    .mvn/wrapper/maven-wrapper.jar
        deleted:    .mvn/wrapper/maven-wrapper.properties
        deleted:    mvnw
        deleted:    mvnw.cmd

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

如果git status打印信息是changes to be committed(已暂存),则直接进入第2步;否则执行命令git rm 如下:

$ git rm .mvn/wrapper/maven-wrapper.jar

$ git rm .mvn/wrapper/maven-wrapper.properties

$ git rm mvnw

$ git rm mvnw.cmd
  • 2、git commit/提交已暂存的文件
$ git commit
[master 569e27b] 删除mvnw等文件
 4 files changed, 369 deletions(-)
 delete mode 100644 .mvn/wrapper/maven-wrapper.jar
 delete mode 100644 .mvn/wrapper/maven-wrapper.properties
 delete mode 100644 mvnw
 delete mode 100644 mvnw.cmd
  • 3、git pull/先同步代码到本地
$ git pull
Already up-to-date.
  • 4、git push origin <本地分支名>/再同步到服务器
$ git push origin master
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 253 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To git@github.com:xiayongchao/angularjs.git
   ef893f7..569e27b  master -> master

命令(修改文件内容时)

  • 1、git status/查看代码的修改状态
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
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)

        modified:   src/main/java/com/xyc/redis/RedisApplication.java

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

  • 2、git add /暂存需要提交的文件
$ git add src/main/java/com/xyc/redis/RedisApplication.java
warning: LF will be replaced by CRLF in src/main/java/com/xyc/redis/RedisApplication.java.
The file will have its original line endings in your working directory.
  • 3、git commit/提交已暂存的文件
$ git commit
[master warning: LF will be replaced by CRLF in src/main/java/com/xyc/redis/RedisApplication.java.
The file will have its original line endings in your working directory.
13e60ac] 添加注释
warning: LF will be replaced by CRLF in src/main/java/com/xyc/redis/RedisApplication.java.
The file will have its original line endings in your working directory.
 1 file changed, 11 insertions(+)
  • 4、git pull/先同步代码到本地
$ git pull
Already up-to-date.
  • 5、git push origin <本地分支名>/再同步到服务器
$ git push origin master
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (9/9), 904 bytes | 0 bytes/s, done.
Total 9 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To git@github.com:xiayongchao/redis.git
   a939a1e..13e60ac  master -> master

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Adam婷

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值