git status 查看状态

git status 查看在你上次提交之后是否有修改。

  1. $ git status
  2. On branch master
  3. Changes not staged for commit:
  4. (use "git add <file>..." to update what will be committed)
  5. (use "git checkout -- <file>..." to discard changes in working directory)
  6. modified: index.txt
  7. no changes added to commit (use "git add" and/or "git commit -a")

参数

  • -s:短格式输出

git diff

执行 git diff 来查看执行 git status 的结果的详细信息。

  1. $ git diff
  2. diff --git a/index.txt b/index.txt
  3. index b2d525b..9472f1c 100644
  4. --- a/index.txt
  5. +++ b/index.txt
  6. @@ -1 +1,2 @@
  7. -index
  8. \ No newline at end of file
  9. +index
  10. +first
  11. \ No newline at end of file

git rm

要从 Git 中移除某个文件,就必须要从已跟踪文件清单中移除,然后提交。

  1. $ git rm index.txt
  2. rm 'index.txt'
  3. $ git commit -m "del"
  4. [master f2ca9d9] del
  5. 1 file changed, 2 deletions(-)
  6. delete mode 100644 index.txt

参数:

  • -f:强制
  • -r:递归删除,删除子文件夹

git mv

git mv 命令用于移动或重命名一个文件、目录、软连接。

  1. $ git mv readme.txt readme.md