我希望了解已知版本控制的文件列表。
我知道在SVN中,您可以执行以下操作:
svn -v status
然后你会得到一个列表,其中包含:
"[rev#1] [rev#2] [创建者] [文件名]"
其中rev#1是具有此文件的最后一次修订,而rev#2是具有此文件的第一次修订。
此列表包含除仅具有本地更改的文件以外的所有由svn跟踪的文件。
我想知道如何使用GIT完成这个操作。
您可以使用以下命令在Git中实现与svn status类似的功能: git status
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 |'"
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 "
git status
这个命令会显示类似于svn status命令的状态信息。
例如:
> $ 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
> ...
为了冗余考虑,重复回答与此类似的问题:
git log --pretty=format: --name-only --diff-filter=A | sort -
git log --pretty=format: --name-status | cut -f2- | sort -u