user8367474
user8367474

Reputation:

Checkout many files

When I wrote git status in the shell, I got

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

Instead of git checkout name_of_the_file, I would like to apply it at a bunch of file. Assume I want to do it with all *.po file, how could I do it with a simple command? Being able to apply at many file in the same file. Could I use xargs? If so, how could I do it?

How to checkout multiple file without taking each of them one by one? I don't want to do git checkout first_file and then git checkout second_file ... For instance, I want to checkout all .po file and .mo file in a simple command line. I wan to learn how to do such a thing.

In clear, I would like someone to show me multiple ways to checkout multiple files for particular words, particular type of files, ...

Upvotes: 1

Views: 4556

Answers (2)

Oleksandr Pryimak
Oleksandr Pryimak

Reputation: 1581

I add a bit from the man

   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> is essentially glob expression with a few tweaks (you can read here https://git-scm.com/docs/gitglossary#gitglossary-glob)

The important to know that **/foo will match the file foo in all subdirectories. Not like */foo which matches only files foo in all child directories

Upvotes: 4

Soham Bhattacharjee
Soham Bhattacharjee

Reputation: 94

use git checkout . to checkout all.

Edit: use git checkout -- *.po to address your issue.

Upvotes: 6

Related Questions