git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git add without whitespace

From
Christian Neukirchen <chneukirchen@gmail.com>
Date
May 31, 2016, 15:59 UTC
Message-ID
<87pos2tdzi.fsf@gmail.com>
In-Reply-To
<xmqqlh2r8ixu.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
> Robert Dailey <rcdailey.lists@gmail.com> writes:
>
>> $ git diff -U0 -w --no-color | git apply --cached --ignore-whitespace
>> --unidiff-zero
>>
>> This command explicitly leaves out context because it can sometimes
>> cause the patch to fail to apply, I think due to whitespace being in
>> it, but I'm not completely sure myself.
>
> I have had this in my ~/.gitconfig for a long time.
>
> [alias]
> 	wsadd = "!sh -c 'git diff -- \"$@\" | git apply --cached --whitespace=fix;\
> 		git co -- ${1-.} \"$@\"' -"
Very useful, thanks for sharing!
I wonder which other gems are in your .gitconfig, is it public?
-- 
Christian Neukirchen  <chneukirchen@gmail.com>  http://chneukirchen.org
Previous: Junio C HamanoNext: demerphq
Message 7 of 8 in “git add without whitespace”
  1. Robert DaileyMay 30, 2016
  2. Junio C HamanoMay 30, 2016
  3. Robert DaileyMay 30, 2016
  4. Junio C HamanoMay 30, 2016
  5. Robert DaileyMay 31, 2016
  6. Junio C HamanoMay 31, 2016
  7. Christian NeukirchenMay 31, 2016
  8. demerphqMay 31, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.