签出许多文件

时间:2017-07-26 04:30:52

标签: git

当我在shell中写git status时,我得到了

deleted by them: CHANGELOG
both modified:   loanwolf/alerts/locale/fr/LC_MESSAGES/django.mo
both modified:   loanwolf/alerts/locale/fr/LC_MESSAGES/django.po
both modified:   loanwolf/clientspace/locale/fr/LC_MESSAGES/django.mo
both modified:   loanwolf/clientspace/locale/fr/LC_MESSAGES/django.po
both modified:   loanwolf/configurations/locale/fr/LC_MESSAGES/django.mo
both modified:   loanwolf/configurations/locale/fr/LC_MESSAGES/django.po
both modified:   loanwolf/contracts/locale/fr/LC_MESSAGES/django.mo
both modified:   loanwolf/contracts/locale/fr/LC_MESSAGES/django.po
both modified:   loanwolf/contrib/locale/fr/LC_MESSAGES/django.mo
both modified:   loanwolf/contrib/locale/fr/LC_MESSAGES/django.po
both modified:   loanwolf/core/locale/fr/LC_MESSAGES/django.mo
both modified:   loanwolf/core/locale/fr/LC_MESSAGES/django.po
both modified:   loanwolf/core/templatetags/locale/fr/LC_MESSAGES/django.mo
both modified:   loanwolf/core/templatetags/locale/fr/LC_MESSAGES/django.po
both modified:   loanwolf/customers/locale/fr/LC_MESSAGES/django.mo
both modified:   loanwolf/customers/locale/fr/LC_MESSAGES/django.po
both modified:   loanwolf/dashboard/locale/fr/LC_MESSAGES/django.mo
both modified:   loanwolf/dashboard/locale/fr/LC_MESSAGES/django.po
both modified:   loanwolf/documents/locale/fr/LC_MESSAGES/django.mo
both modified:   loanwolf/documents/locale/fr/LC_MESSAGES/django.po
both modified:   loanwolf/employees/locale/fr/LC_MESSAGES/django.mo
both modified:   loanwolf/employees/locale/fr/LC_MESSAGES/django.po
deleted by them: loanwolf/equifax_report/locale/fr/LC_MESSAGES/django.mo
deleted by them: loanwolf/equifax_report/locale/fr/LC_MESSAGES/django.po
deleted by them: loanwolf/loans/locale/fr/LC_MESSAGES/django.mo
deleted by them: loanwolf/loans/locale/fr/LC_MESSAGES/django.po
deleted by them: loanwolf/messaging/locale/fr/LC_MESSAGES/django.mo
deleted by them: loanwolf/messaging/locale/fr/LC_MESSAGES/django.po
deleted by them: loanwolf/notes/locale/fr/LC_MESSAGES/django.mo
deleted by them: loanwolf/notes/locale/fr/LC_MESSAGES/django.po
deleted by them: loanwolf/operations/cron.py
deleted by them: loanwolf/operations/locale/fr/LC_MESSAGES/django.mo
deleted by them: loanwolf/operations/locale/fr/LC_MESSAGES/django.po
deleted by them: loanwolf/perception/locale/fr/LC_MESSAGES/django.mo
deleted by them: loanwolf/perception/locale/fr/LC_MESSAGES/django.po
deleted by them: loanwolf/products/locale/fr/LC_MESSAGES/django.mo
deleted by them: loanwolf/products/locale/fr/LC_MESSAGES/django.po
deleted by them: loanwolf/requests/formlayouts.py
deleted by them: loanwolf/requests/forms.py
deleted by them: loanwolf/requests/locale/fr/LC_MESSAGES/django.mo
deleted by them: loanwolf/requests/locale/fr/LC_MESSAGES/django.po
deleted by them: loanwolf/requests/utils.py
deleted by them: loanwolf/requests/views.py
deleted by them: loanwolf/statistics/locale/fr/LC_MESSAGES/django.mo
deleted by them: loanwolf/statistics/locale/fr/LC_MESSAGES/django.po
deleted by them: loanwolf/users/locale/fr/LC_MESSAGES/django.mo
deleted by them: loanwolf/users/locale/fr/LC_MESSAGES/django.po

而不是git checkout name_of_the_file,我想在一堆文件中应用它。假设我想用所有*.po文件来做,我怎么能用一个简单的命令呢?能够在同一文件中的多个文件中应用。我可以使用xargs吗?如果是这样,我怎么能这样做?

如何一个接一个地检出多个文件?我不想做git checkout first_file然后git checkout second_file ...例如,我想在一个简单的命令行中检出所有.p​​o文件和.mo文件。我想学习如何做这样的事情。

很明显,我希望有人向我展示多种方法来检查特定单词的多个文件,特定类型的文件,......

2 个答案:

答案 0 :(得分:5)

使用git checkout .结帐全部。

修改:使用git checkout -- *.po解决您的问题。

答案 1 :(得分:2)

我从男人那里加了一点

   git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...
       When <paths> or --patch are given, git checkout does not switch branches. It updates the named paths in the working tree from the index file or from a
       named <tree-ish> (most often a commit). In this case, the -b and --track options are meaningless and giving either of them results in an error. The
       <tree-ish> argument can be used to specify a specific tree-ish (i.e. commit, tag or tree) to update the index for the given paths before updating the
       working tree.

       git checkout with <paths> or --patch is used to restore modified or deleted paths to their original contents from the index or replace paths with the
       contents from a named <tree-ish> (most often a commit-ish).

       The index may contain unmerged entries because of a previous failed merge. By default, if you try to check out such an entry from the index, the
       checkout operation will fail and nothing will be checked out. Using -f will ignore these unmerged entries. The contents from a specific side of the
       merge can be checked out of the index by using --ours or --theirs. With -m, changes made to the working tree file can be discarded to re-create the
       original conflicted merge result.

<pathspec>基本上是带有一些调整的glob表达式(你可以在这里阅读https://git-scm.com/docs/gitglossary#gitglossary-glob

重要的是要知道**/foo将匹配所有子目录中的文件foo。不像*/foo只匹配所有子目录中的文件foo