7

I want to know the list of files that are known to version control.

I know that in SVN, you can do something like:

svn -v status 

then you get a list of

"[rev#1] [rev#2] [creator] [file name]"

rev#1 is the last revision that has this file and rev#2 is the first revision that has this file.

This list contains all the files that are tracked by svn other than only the ones that have local changes.

I wonder how to do this using GIT

2 Answers 2

4

You do have this proposition for an equivalent of svn status with 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 |'" 

I suspect git log --name-status mentioned by Techism (in the comments) in this SO question might make the alias shorter.

Its variant is actually based on 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 " 
Sign up to request clarification or add additional context in comments.

Comments

3

git status

That shows a status much like svn status command.

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 > ... 

For redundancy sake, repeating answer from this similar question:

List all the files that ever existed in a Git repository

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

or

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

4 Comments

"svn -v status" shows all the files that are tracked by svn. I think "git status" only shows the files that are locally changed.
Actually: This thread answers your question I think... stackoverflow.com/questions/543346/…
thanks, the command that you posted above does help me quite a bit. Is there any way to filter out the files that no longer exist?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.