git checkout arquivos específicos

1

No momento, quando executo git status , recebo

modified:   loanwolf/alerts/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/alerts/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/clientspace/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/clientspace/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/configurations/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/configurations/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/contracts/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/contracts/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/contrib/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/contrib/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/core/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/core/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/core/templatetags/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/core/templatetags/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/customers/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/customers/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/customers/models.py
modified:   loanwolf/dashboard/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/dashboard/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/documents/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/documents/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/employees/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/employees/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/equifax_report/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/equifax_report/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/loans/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/loans/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/messaging/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/messaging/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/notes/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/notes/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/operations/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/operations/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/perception/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/perception/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/products/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/products/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/requests/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/requests/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/requests/models.py
modified:   loanwolf/statistics/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/statistics/locale/fr/LC_MESSAGES/django.po
modified:   loanwolf/users/locale/fr/LC_MESSAGES/django.mo
modified:   loanwolf/users/locale/fr/LC_MESSAGES/django.po

Eu quero limpar a saída para remover modified: e os arquivos

loanwolf/requests/models.py
loanwolf/customers/models.py
loanwolf/requests/locale/fr/LC_MESSAGES/django.po

Na verdade, quero manter todo o arquivo, exceto os três últimos. Como eu pude fazer isso?

No momento, acho que consegui fazer git status | grep -v 'request' . Eu quero git checkout todos os arquivos, exceto os três arquivos.

git status | grep 'modified:' | awk '{print $2}' | xargs git [diff|add|checkout] ????

    
por J.Doe 16.08.2017 / 21:27

1 resposta

1

Eu faria desta maneira:

  • confirme os arquivos que deseja manter (temporariamente)

    git commit -m WIP loanwolf/requests/models.py loanwolf/customers/models.py loanwolf/requests/locale/fr/LC_MESSAGES/django.po
    
  • verifique tudo o resto

    git checkout .
    
  • redefinir para desfazer o commit (isso não perderá nenhuma alteração)

    git reset HEAD^1
    

Se você quiser brincar com git status , confira git status -s , sua saída é mais fácil de processar de forma confiável.

    
por 17.08.2017 / 06:40

Tags