git equivalent of "svn -v status"
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 开发者_如何学Pythonfiles that are tracked by svn other than only the ones that have local changes.
I wonder how to do this using GIT
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 "
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
精彩评论