【问题标题】:What is git status alternative for ! svn status result什么是 git status 替代品! svn状态结果
【发布时间】:2019-08-24 23:52:11
【问题描述】:

我正在修改一个脚本来检查以下结果代码的 svn 状态:!

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

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

SVN 结果示例:

svn status
! trunk/script/test.txt

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

感谢您的帮助!

【问题讨论】:

    标签: git svn


    【解决方案1】:

    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 addgit 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 更难修改和撤消。

    【讨论】:

    • 所以如果在我的代码中我有函数 svnAdd "if result == ? then (run svn add file) else if result == ! then (svn rm file) then in gitAdd function 我必须覆盖两个 D 其中 D 在第一列和第二列?
    • @Kecaj First D 表示它已经准备好删除。您只需要为第二个 D 执行 git rm。如果您的意图是简单地添加/rm 所有更改,请使用 git add -A
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-09-05
    • 1970-01-01
    • 2019-02-22
    • 2011-05-07
    • 2012-04-24
    • 2019-12-03
    • 2010-09-17
    相关资源
    最近更新 更多