Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git equivalent of "svn -v status"

Tags:

git

svn

git-svn

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

like image 680
Vicky Avatar asked Mar 12 '11 00:03

Vicky


People also ask

What is SVN in git?

What is Git-SVN? The git-svn tool is an interface between a local Git repository and a remote SVN repository. Git-svn lets developers write code and create commits locally with Git, then push them up to a central SVN repository with svn commit-style behavior.

Can git be used in Subversion?

From a Subversion Repository to Git Remotes A Subversion checkout can point to one and only one repository, and all work is done against that repository. With Git, however, it is possible to configure multiple connections to multiple remote repositories. You do this by using Git remotes.


2 Answers

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 "
like image 101
VonC Avatar answered Sep 30 '22 21:09

VonC


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
like image 33
Techism Avatar answered Sep 30 '22 19:09

Techism