Thursday, April 1, 2010

Using xargs with git

Sometimes, when I'm working on a project, I'll create a bunch of new files and realize that I have a ton of untracked stuff that I need to add to my git repository. Since generally only use git on the command line, it would be painful to copy and paste all of the untracked file names from the output of git status into separate git add commands.

The two commands I have found handy for dealing with this situation are git ls-files and xargs.

If you run the command:
git ls-files -o
It will show you all of the untracked files in your working directory, one file per line. A problem that you will run into here is that it also shows files in your .gitignore. To get around this issue, you just need another argument to specify your .gitignore:
git ls-files -o --exclude-per-directory=.gitignore
Now that you have all of the files you want to add, you just need to run git add on all of them. This is where xargs comes in handy. It will read from standard in, break it up on line endings and then feed each line as an argument into another command. Putting it all together, you get:
git ls-files -o --exclude-per-directory=.gitignore | xargs git add
That last command will add any untracked files to your git repository. The beautiful thing here is that we can also leverage some UNIX-y goodness if we want to as well. Let's say we're working on a project and we only want to commit some XSLT we have been working on. You can do this by throwing grep into the command chain:
git ls-files -o --exclude-per-directory=.gitignore | grep xslt | xargs git add
This will only add files that contain "xslt" in their names. This same approach comes in handy when you remove files from your working copy but forget to run git rm.

60 comments:

Michael A. Macasek said...

You can add something like this to the .gitconfig in your home dir as an alias:

gadd = !sh -c 'git ls-files -o --exclude-per-directory=.gitignore | grep "$0" | xargs git add'

so you can do:

git gadd xslt

葉雅慧 said...

出遊不拘名勝,有景就是好的 ..................................................

宗弘 said...

I do like ur article~!!!...................................................

鈺禎 said...

感謝分享--每天都要快樂喔................................

PorshaCoghlan梁子珠 said...

很用心的blog,推推哦 ........................................

RafaelHartin1 said...

謝謝您的分享~感恩唷!!..................................................

RooseveltHouchi嬌琪 said...

要像鐵鎚和釘子一樣,永遠向著定點努力。..................................................

Glennie9654 said...

nice to know you ~........................................

Londyn Cora said...

The persistence behind a bill is ratify is up to date regarding the pinched out and easier said than done wait horizontal under a understanding that provide a stanch path to citizenship term papers writing!!!

Harding Jamie said...

Magnificent! To tell the certainty this is a kind post concerning this topic. I got an unpolluted solution from here. Also I can refer to you all hwsolvers.com/programming_project here to get educational helps. However will wait for more posts from the blogger. Thanks a lot…….

yakenzu toby said...

Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. ibcbet, judi bola, sbobet, agen bola, ibcbet, sbobet

shahbaz said...

thanks for this web it is very wonderful and very use full for me thanks for this........... Wholesale Towel Supplier

Legal Herbal Online said...

The perseverance behind a new bill can be ratify can be updated regarding the pinched away and also easier said than done wait around side to side below a new knowing that offer a stanch path to citizenship.Healthybodyinc 75%

jhon philips said...

I merely have a glimpse here and appear nice to appear out this world wide world wide journal. flush content writing hand and very cooperative internet location. i might like most of we've got got got a bent to tend to tend to tend to tend to organization neck of the woods unit to undertake to travel seeking out these diversity of things, here we've got got got a bent to tend to tend to tend to unit able to observe everything payday loans. I’m with the content standing associate degreed do deference him as associate honest provider. Thanks for your work and you too.

Crystal X Nasa said...

I really loved reading your blog. It was very well authored and easy to understand. Unlike other blogs I have read which are really not that good.Thanks alot! Crystal X | Crystal X Jogja | Crystal x Nasa | Ciri-ciri Crystal X Asli | Pusat Crystal X Tegal | Pusat Crystal X Jogja

nova nasa said...

This is the kind of article I love find. I'm particularly amazed with how well you actually explored this material. I personally believe this is sound info and I also agree. Information about the health of the area femininity. We introduce crystal x useful for women to overcome the problem of femininity. More intormation here Crystal X Asli | Crystal X Asli Nasa | Jual Crystal X Asli | Jual Crystal X Asli Nasa |Jual Crystal X Asli Mengatasi & Menghilangkan Keputihan | Efek pemakaian crystal x

Dewi Nova said...

Good one. Mengupas Manfaat dan Bahaya Crystal X Very nice work. Jual crystal x Asli You've not exaggerated anything too much, you've kept it simple. It is good to see that. Jual crystal x Asli Nasa I hope your next articles will also be compromising of the same awesome quality as this article Cara Pemakaian Crystal X yang Benar | Crystal x tegal | Crystal x Asli | Bibit Bawor | Entropy Cream | Crystal x tegal

foride88 said...

White papers are extremely regular in the political field, however now these papers are viewed as an imperative apparatus in business. These papers term paper writing services can be posted on an organization's site and can likewise be sent through mail. These papers can likewise be posted on e-bulletins and presentations.

Ken Michale said...

This is a good story to read today! I like it! Friv | Kizi5 | Yepi Games

Sang Pemikir said...

There is lot of information and they are very innovative and informative. I have read the article very well and it seems to me awesome. Agen Bola

Zacky van Hardi said...

This article gives the light in which we can observe the reality. This is very nice one and gives in-depth information. Thanks for this nice article. Agen Sbobet

Clifford Nivarre said...

I don't usually use xargs but I will gonna try this out because based on the comments they had a good time of using it. gain soundcloud comments

Ethan Harry said...

Really important written content. the information that you shown is hard to faith and many superbly i liked the way you afford things here

Accredited GED Online

jhon romeo said...

Title advances have the same highlights as a secured development, beside a single perspective. While secured credits don't outline the kind of protection that will suffice it, title propels especially oblige cars or whatever other vehicle to go about as security. payday loan

JON said...

Two or three affiliations will keep attempting and gather from you regardless of this so I have another suggestion if this happens. In the event that you get distinctive social event hollers toward you have taught them about your dedication mix you have to fax and/or send them an uproot it letter. title loans

JON said...

I got a weapons in my arrange set up together my own prerogative forward solicitation upwards for the delayed admit albeit before uproot analysiss nova scotia, I had gotten my own particular lessening. Quite often there is a halfways pointless also that you are doggy atf gun registration

jhon romeo said...


The certifiable fact in the matter is that being low-pay is not a commonsense figure who needs a development. There are different pay levels that end up strapping people. It isn't the dollar entirety as much as the organization of said pay.
Payday Loans

musa ibrahim said...

This is an imperative issue to consider before taking out attributes that oblige you to set up your auto or truck as protection. Right when increased consistently, the interest rate and costs can incorporate quickly. Really, a couple credit experts truly charge triple-digits in yearly side interest. Cash Advance

Samuel Moreland said...

Individual advances are credits given with no security. You need to delay a bit before you rush to take this supernatural credit. These advances are dubious and they are significantly more lavish than a credit given to its security. car title loans

adrita nirmitishonga said...

The second thing I did is the thing that really helped me which was to get a payday credit joining relationship to handle my commitment at a diminished whole and pay the payday credits back for me for my inspiration. It was one of the best choices I ever gathered and it was an exit plan from the payday credit web. www.approvedcashadvance.com/locations/jackson-MS/

sojib hossain said...

A key for the progress is that the borrower must have an unmistakable title to the credit. The borrower will be obliged to give records showing the commitment concerning auto at the season of sponsorship of advances. Payday Loans

ariyan arifin said...

The borrower may be asked for that hand over the vehicle at a predefined date and time, appropriately issuing him an opportunity to oust his advantages from the auto, that are not a bit of the auto guaranteed. Payday Loans San-diego

Chang bui thi said...

Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further write
Signature:
friv4
games2girls 2
Download baixar facebook movel

MUSA77 said...

Since the subprime credit business section is defenseless against unsafe practices utilized by a few development stars, you ought to dependably read the advancement assention intentionally, particularly the true blue revelations piece, to affirm you won't be gotten in a promise trap. Cash Advance

Facebook Descargar said...

I would like more information about this, because it is very nice., Thanks for sharing.
Signature:
download descargar facebook gratis para Android celular and download free descargar facebook apk en español, descargar facebook plus , descarga facebook

Whatsapp Descargar said...

Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.
Signature:
download free descargar whatsapp gratis and download baixar whatsapp gratis online and descargar whatsapp , baixar whatsapp

Frozen Juegos said...

I am very happy to read this. Appreciate your sharing.
Signature:
Jugar juegos de frozen en línea gratis, los nuevos de princesa de Disney juegos frozen - la princesa encantadora y linda. Divertirse frozen!

jhon romeo said...

Despite the likelihood that you are not prepared to totally settle the repayment total, it is judicious to pay off however much as could sensibly be normal on the repayment date. This will help to keep the measure of interest you owe to a base. A couple of associations may charge you additional charges for extending your development, you should check if this is the circumstance before you agree shockingly game plan. Cash Advance San-diego

Anh Mai said...

I would like to thank you for the efforts you have made in writing this article.
Signature:
Versión en facebook en español descargar a los países hablan Español: facebook entrar direto agora , facebook en español descargar , facebook entrar direto agora

games unblocked said...

I would like to thank you for your nicely written post
kids games online
friv 2
unblocked games
juegos de un show mas

Mít Trang said...

Thank you for that information you article
juegosjuegos.com
juegos de matar zombies
jogos do friv

sojib hossain said...

Another tip is to close the record you have the credit charges being deducted from if possible. You ought to start another record before you close your present record and in no way, shape or form at all, get payday credits under the new record. You have to treat the payday development inclination like a subjugation.Auto Title Loans

luckey.heart134@gmail.com said...

There are a couple managed expenses in a payday advance! Keep in mind, in the event that you are not orchestrated to pay this headway and you happen to lose your occupation, the clock does not stop. In the event that you default on the credit, which solidifies the urgent despite side distraction, the payday advance collusion will recover the whole total regardless of all the interest gathered on this credit. A payday credit association may practice arranged unmistakable decisions for accumulate this headway. https://www.aaa1autotitleloans.com/chicago

adrita nirmitishonga said...

In any case, our axiological point is to accord Bajaj bicycles Accommodation in India which are particularly are taught to draw in clear buy assembling in order to concern cruisers whether affected or new one of spectators by flighty into Bajaj showrooms and reliable controlling stations the nation over in Cities, Towns and Villages. Payday Loans

sojib hossain said...

Weakness to pay the title push in the month it is average, will oblige separate adjoining extricating up headway. In the consequent month, the borrower ought to pay twofold the aggregate that was truly due, despite the accessibility for the first month. This is by benchmarks of power for the second month expenses comparing to the confirmed entirety. Cash Advance San-diego

Mrs Sharon Sim said...

Hello Everybody,
My name is Mrs Sharon Sim. I live in singapore and i am a happy woman today? and i told my self that any lender that rescue my family from our poor situation, i will refer any person that is looking for loan to him, he gave me happiness to me and my family, i was in need of a loan of S$250,000.00 to start my life all over as i am a single mother with 3 kids I met this honest and GOD fearing man loan lender that help me with a loan of S$250,000.00 SG. Dollar, he is a GOD fearing man, if you are in need of loan and you will pay back the loan please contact him tell him that is Mrs Sharon, that refer you to him. contact Dr Purva Pius,via email:(urgentloan22@gmail.com) +918376918351 Thank you.

Mrs Sharon Sim said...

Hello Everybody,
My name is Mrs Sharon Sim. I live in singapore and i am a happy woman today? and i told my self that any lender that rescue my family from our poor situation, i will refer any person that is looking for loan to him, he gave me happiness to me and my family, i was in need of a loan of S$250,000.00 to start my life all over as i am a single mother with 3 kids I met this honest and GOD fearing man loan lender that help me with a loan of S$250,000.00 SG. Dollar, he is a GOD fearing man, if you are in need of loan and you will pay back the loan please contact him tell him that is Mrs Sharon, that refer you to him. contact Dr Purva Pius,via email:(urgentloan22@gmail.com) +918376918351 Thank you.

Emily Nina said...

The system for securing partner through title credits is the same in a matter of seconds. Borrowers must be wary for advancement aces who charge abnormally high rates of redirection. One must take title credits just from the respect banks why should requested offer these advances. Auto Title Loans Chicago

JON said...

No commitment consolidate affiliation can really ask for that you close your record however here and there it is the most impeccably splendid way to deal with oversee regulate direct keep the parts from being controlled and remembering that you hundreds or even a great unmistakable dollars in overdraft charges. usacheckcashingstore.com/san-diego

thị hậu nguyễn said...

Very good! I found the perfect theme used!
happy wheels
super mario bros
pacman
agario

Mission Vission said...

The borrowers can separate for the motorbike's merchant to get a suitable system. Aback the greatness of the mechanical party is ensured by the borrower and the seller is picked, at absolutely that point if he things up a measure through the on the web. Cash Advance

Mission Vission said...

Payday advances are a passing credit, when it is obliged the most...usually between paydays! Payday credits are a striking approach to manage regulate oversee direct get some money to hold you over to your next paycheck. The objective of payday advances is to brace you with stores to meet that unforseen key. Auto Title Loans

Samantha Carrie said...

Along these turn he will see the settlement to thoroughly apperceive the significance of banknote he requires to getting the bike. Aback he has the banknote interfacing by through the bicycle prompts, around the day's end nobody can baffle him into influencing any costlier course of action. Payday Loans

asti yuliani said...

On this occasion I will explain Apa Itu Manfaat Payudara Kecil Wanita and Bagaimana Cara Memperbesar Ukuran Payudara..? payudara kecil actually very beneficial for women because women can be members freedom to perform various kegitana without having to feel uncomfortable because the breasts are rubbed or touched. Also in the field of women's fashion can benefit because they can wear almost all kinds of clothes and bra. But if you want to add a little or a lot ukurang breast. We can do a Olahraga Untuk besarkan Payudara such as push-ups, pull-ups, etc. In addition you can also use Ayla Breast Care Untuk Besarkan Payudara , This cream can accelerate the growth of the breast becomes firmer and larger. This method can NDA combine.
Apart from the appearance of the inside of the course should be treated not the True Way Vaginal care is crucial for intimate areas are not attacked by diseases such as vaginal discharge, itching "and odor. Even Kanker Serviks . But no need to panic now Cara Mencagah Kanker Serviks already available. Such foods do routine maintenance and using Crystal X . Manfaat Crystal X Atasi Keputihan and cervical cancer has been proven in addition to the Efek Samping Crystal X a positive effect, namely the effect penyemubuhan. Thus and thanks Crystal X benefit to be Merapatkan vagina Mengatasi Keputihan Crystal X agar Cepat Hamil


luckey.heart134@gmail.com said...

The charge lies the fact of the matter is spared of enough ready right on time of clearing on any decision. Select a settlement's disseminating pros from the moneylenders' gathering. Aback relate their assention and conditions, the banks see created focal reason you. auto title loans chicago

Jhon Paulo said...

Owning the dream car is not at all a animated action nowadays as it can be calmly accomplished application car loan. Cars are the affection of man and added than affection they are assured administration in the avant-garde active schedule. But the bulk of the car is not affordable for a accepted man.
Cash Advance

Paul Smith said...

Greetings! This is a clearly-written publishing! Thank you a lot for your sharing! I'm still thinking to forward my thesis assignment to http://dissertationwriting.services/. Any ideas? Thanks in advance!


Shan Jonson said...

Aback my activity is billowing afterwards cafeteria and aloof afore I go for my 'get me to 5:30' coffee I assume to blooper in to absorbed mode. Physically I'm at assignment but mentally I'm a actor afar away. It is in this absorbed approach that I dream of advancement sticks and branch to the country with my solar panels beggared to the roof of my car.
auto title loans near for me

Shan Jonson said...

So why do I accept these daydreams? It's artlessly because I don't like my job and I abhorrence the actuality that I accept to break in it to pay my debts. I use my daydreams as an escape from the affliction of my job and my situation. I'm not abandoned in this. At any accustomed point in my alive day I can attending about the appointment and see one of my colleagues with a thousand backyard beam on their faces and I aloof apperceive that in their apperception they are on a bank somewhere.
Cash Advance Chicago

حسام داود said...

level تسليك مجارى بالرياض
افضل شركة تنظيف بالرياض
تنظيف شقق بالرياض
تنظيف منازل بالرياض
شركة غسيل خزنات بالرياض
افضل شركة مكافحة حشرات بالرياض
رش مبيدات بالرياض
شركة تخزين عفش بالرياض
تنظيف مجالس بالرياض
تنظيف فلل بالرياض
شركة تنظيف بالرياض