1

In the moment, when I run git status, I got

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

I want to clean the output to remove modified: and the files

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

In fact, I want to keep all the file except those three last. How could I do that?

For the moment, I think I could do git status | grep -v 'request'. I want to git checkout all files except those three files.

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

2

1 Answer 1

1

I would go about it this way:

  • commit the files you want to keep (temporarily)

    git commit -m WIP loanwolf/requests/models.py loanwolf/customers/models.py loanwolf/requests/locale/fr/LC_MESSAGES/django.po
    
  • check everything else out

    git checkout .
    
  • reset to undo the commit (this won’t lose any changes)

    git reset HEAD^1
    

If you do want to play around with git status, check out git status -s, its output is easier to process reliably.

2
  • 1
    You could probably also use a "stash"? I've done that myself, but only once or twice with a GUI. It basically means you're stashing some file away for a while, then you pull the latest commits, then apply the stashed files to the repository.
    – Kusalananda
    Aug 17, 2017 at 15:42
  • @Kusalananda a stash would be more convenient, but git stash stores the complete workspace state, it can’t filter (AFAIK). You’re right though that my use of a commit here is more akin to a stash than a proper commit. Some GUIs have stashing variants that support filtering, those would work too. Aug 17, 2017 at 15:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .