当前位置:   article > 正文

Git文件状态描述

git上传状态描述表示什么意思

检查当前文件状态

  1. [root@typhoeus79 ice_test_m git_test]# git status
  2. # On branch master
  3. nothing to commit (working directory clean)

说明当前git目录很干净,所有已跟踪的文件在上次提交后没有修改过。当前的分支为master

 

Untracked状态

touch创建一个README文件后

  1. [root@typhoeus79 ice_test_m git_test]# touch README
  2. [root@typhoeus79 ice_test_m git_test]# git status
  3. # On branch master
  4. # Untracked files:
  5. # (use "git add <file>..." to include in what will be committed)
  6. #
  7. # README
  8. nothing added to commit but untracked files present (use "git add" to track)

出现Untracked状态,说明有git在之前的提交中没有这些文件。

NewFile状态

使用git add跟踪这个文件

  1. [root@typhoeus79 ice_test_m git_test]# git add README
  2. [root@typhoeus79 ice_test_m git_test]# git status
  3. # On branch master
  4. # Changes to be committed:
  5. # (use "git reset HEAD <file>..." to unstage)
  6. #
  7. # new file: README
  8. #

在 “Changes to be committed” 这行下面的,就说明是已暂存状态。

git add 的潜台词就是把目标文件快照放入暂存区域,也就是 add file into staged area,同时未曾跟踪过的文件标记为需要跟踪。

modified状态

编辑README文件,写入新内容

  1. [root@typhoeus79 ice_test_m git_test]# echo 11 >README
  2. [root@typhoeus79 ice_test_m git_test]# cat README
  3. 11
  4. [root@typhoeus79 ice_test_m git_test]# git status
  5. # On branch master
  6. # Changes to be committed:
  7. # (use "git reset HEAD <file>..." to unstage)
  8. #
  9. # new file: README
  10. #
  11. # Changes not staged for commit:
  12. # (use "git add <file>..." to update what will be committed)
  13. # (use "git checkout -- <file>..." to discard changes in working directory)
  14. #
  15. # modified: README
  16. #

出现在 “Changes not staged for commit” 这行下面,说明已跟踪文件的内容发生了变化,但还没有放到暂存区。要暂存这次更新,需要运行 git add 命令

再次运行git add之后,状态如下:

  1. [root@typhoeus79 ice_test_m git_test]# git add README
  2. [root@typhoeus79 ice_test_m git_test]# git status
  3. # On branch master
  4. # Changes to be committed:
  5. # (use "git reset HEAD <file>..." to unstage)
  6. #
  7. # new file: README
  8. #

Commit操作-提交更新

  1. [root@typhoeus79 ice_test_m git_test]# git push
  2. Everything up-to-date
  3. [root@typhoeus79 ice_test_m git_test]# git status
  4. # On branch master
  5. # Changes to be committed:
  6. # (use "git reset HEAD <file>..." to unstage)
  7. #
  8. # new file: README
  9. #

紧接着直接push的话,会出现“Everything up-to-date”,但是查看git status,README还一个新文件,只是被commited而已

需要执行一次commit

  1. [root@typhoeus79 ice_test_m git_test]# git add README
  2. [root@typhoeus79 ice_test_m git_test]# git status
  3. # On branch master
  4. # Changes to be committed:
  5. # (use "git reset HEAD <file>..." to unstage)
  6. #
  7. # new file: README
  8. #
  9. [root@typhoeus79 ice_test_m git_test]# git commit -m "commit"
  10. [master 0ec3465] commit
  11. 1 files changed, 1 insertions(+), 0 deletions(-)
  12. create mode 100644 README
  13. [root@typhoeus79 ice_test_m git_test]# git status
  14. # On branch master
  15. # Your branch is ahead of 'origin/master' by 1 commit.
  16. #
  17. nothing to commit (working directory clean)

当前工作环境已经clean,branch方式有1个commit

 

Push操作-推送到远程仓库上

  1. [root@typhoeus79 ice_test_m git_test]# git push
  2. Counting objects: 4, done.
  3. Writing objects: 100% (3/3), 234 bytes, done.
  4. Total 3 (delta 0), reused 0 (delta 0)
  5. remote: => Syncing Gitorious... [OK]
  6. To git@10.210.213.9:code_guosong/git_test.git
  7. ecc80ec..0ec3465 master -> master
  8. [root@typhoeus79 ice_test_m git_test]# git status
  9. # On branch master
  10. nothing to commit (working directory clean)

上面的1个commit已经没有,回到初始的状态

转载于:https://www.cnblogs.com/gsblog/p/4027702.html

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

闽ICP备14008679号