2011-03-12 47 views
7

我想知道版本控制已知的文件列表。git相当于“svn -v status”

我知道,在SVN,你可以这样做:

svn -v status 

那么你得到的

列表“[转#1] [转#2] [创造者] [文件 名]”

转#1是有这个文件,并转#2是有这个文件的第一个修订版的最后一个版本。

此列表包含svn跟踪的所有文件,而不是仅包含本地更改的文件。

我不知道如何使用GIT

回答

4

你做H的AVE this proposition关于svn地位等同用git:

git config alias.svn-status \!"\ 
{ \ 
git ls-files -o --directory -t ; \ 
git status | grep --color=never 'deleted: ' | sed 's|^.*deleted: ||' | sed 's|^|D |' ; \ 
git ls-files -m -s | awk '{print \$NF}' | sort -u | sed 's|^|M |' ; \ 
} \ 
| sort -k 2 \ 
| sed 's|^\\(.\\) *|\\1  |'" 

我怀疑在这SO question通过Techism提到git log --name-status(在评论)可能使别名短。

它的变种实际上是基于diff --name-status

svn-status = "! git ls-files --exclude-per-directory=.gitignore --exclude-from=.git/info/exclude --exclude-from=$HOME/.gitignore --others -t | sed 's| |\t|'; git diff HEAD --name-status " 
3

git的状态

,显示了状态很像svn status会做到这一点。

EG:

> $ git status 
> # On branch master 
> # Your branch is ahead of 'origin/master' by 2 commits. 
> # 
> # Changed but not updated: 
> # (use "git add/rm <file>..." to update what will be committed) 
> # (use "git checkout -- <file>..." to discard changes in working 
> directory) 
> # 
> # modified: Gemfile 
> # modified: Gemfile.lock 
> # modified: app/controllers/application_controller.rb 
> # modified: app/controllers/home_controller.rb 
> # modified: app/controllers/projects_controller.rb 
> ... 

对于冗余的缘故,从这个类似的问题重复回答:

List all the files that ever existed in a Git repository

git log --pretty=format: --name-only --diff-filter=A | sort - 

git log --pretty=format: --name-status | cut -f2- | sort -u 
+2

“SVN -v状态” 显示所有被跟踪SVN的文件。我认为“git status”只显示本地更改的文件。 – Vicky 2011-03-12 00:58:45

+0

或者你想要git diff? – Techism 2011-03-12 01:02:51

+0

其实:这个线程回答你的问题,我想... http://stackoverflow.com/questions/543346/git-list-all-the-files-that-ever-existed – Techism 2011-03-12 01:03:57