Kecaj
Kecaj

Reputation: 35

What is git status alternative for ! svn status result

I am modifying a script which checks svn status for following result code: !

In the documentation I can see that ! corresponds to following description:

Item is missing (e.g., you moved or deleted it without using svn). This also indicates that a directory is incomplete (a checkout or update was interrupted).

Example SVN result:

svn status
! trunk/script/test.txt

Can someone tell what is the git result alternative for !. I have checked git documentation but I am not sure if svn ! corresponds to D.

Thanks for helping!

Upvotes: 0

Views: 314

Answers (1)

Schwern
Schwern

Reputation: 165546

SVN and Git work a bit differently in this regard. The rough Git equivalent is deleted from the working directory, but not staged.

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

You can get a short version with git status -s in which case it's a D in the second column.

$ git status -s
 D this

Git has a "staging area" which can be thought of as a place to build up a new commit. You make changes to your working directory (ie. the files on disk) and then "stage" them with git add and git rm. Then git commit commits what is staged.

Git is ok with you adding, deleting, and changing files outside Git. It will not commit them unless explicitly staged.

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

    deleted:    this

And the short version is a D in the first column.

$ git status -s
D  this

See git status for more.


In contrast SVN does not have a staging area; what is changed on disk is what is committed. Thus deleting a tracked file without telling SVN is abnormal; it's possible you did not mean to delete the file. And SVN commits are much harder to revise and undo than in Git.

Upvotes: 1

Related Questions