首页 > 解决方案 > 什么是 git status 替代品!svn状态结果

问题描述

我正在修改一个脚本,它检查 svn 状态以获取以下结果代码:!

在文档中我可以看到!对应于以下描述:

项目丢失(例如,您在没有使用 svn 的情况下移动或删除了它)。这也表明目录不完整(签出或更新被中断)。

SVN 结果示例:

svn status
! trunk/script/test.txt

有人可以告诉 git 结果替代品是什么!。我检查了 git 文档,但我不确定是否 svn !对应于 D。

感谢您的帮助!

标签: gitsvn

解决方案


SVN 和 Git 在这方面的工作方式略有不同。粗略的 Git 等效项已从工作目录中删除,但未暂存。

$ rm this 
$ git status
On branch 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:    this

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

你可以得到一个简短的版本,git status -s在这种情况下,它是第二列中的 D。

$ git status -s
 D this

Git 有一个“暂存区”,可以将其视为构建新提交的地方。您对工作目录(即磁盘上的文件)进行更改,然后使用git addand将它们“暂存” git rm。然后git commit提交暂存的内容。

Git 可以在 Git 之外添加、删除和更改文件。除非明确分阶段,否则它不会提交它们。

$ git rm this 
rm 'this'
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    deleted:    this

简短版本是第一列中的 D。

$ git status -s
D  this

查看git status更多。


相比之下,SVN 没有暂存区;磁盘上更改的内容就是提交的内容。这样不告诉SVN就删除跟踪文件是不正常的;您可能不是有意删除该文件。SVN 提交比 Git 更难修改和撤消。


推荐阅读