..." to update what will ...">
当前位置:   article > 正文

使用git命令提交代码

使用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")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

如果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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 3、git pull/先同步代码到本地
$ git pull
Already up-to-date.
  • 1
  • 2
  • 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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

命令(修改文件内容时)

  • 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")

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 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.
  • 1
  • 2
  • 3
  • 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(+)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 4、git pull/先同步代码到本地
$ git pull
Already up-to-date.
  • 1
  • 2
  • 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/694364
推荐阅读
相关标签
  

闽ICP备14008679号