{"thread":{"id":"53794","subject":"commiting a change from command line with newlines.","startedAt":"2020-07-03T04:22:15Z","lastAt":"2020-07-03T05:21:57Z","messageCount":4,"participants":["Tomas","Junio C Hamano","brian m. carlson","Kevin Daudt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"401000","messageId":"17312e90c37.fefa495d137526.1559287962218705021@tomaszubiri.com","threadId":"53794","inReplyTo":null,"subject":"commiting a change from command line with newlines.","fromName":"Tomas","fromEmail":"correo@tomaszubiri.com","sentAt":"2020-07-03T04:22:09Z","receivedAt":"2020-07-03T04:22:15Z","isPatch":false,"sender":{"key":"correo@tomaszubiri.com","avatar":null},"body":"Hello,\n\nI'm trying to write stanzas in my commit message, and naturally the ASCII newline character is the best tool for this, beautifully integrated throughout my whole system, from my keyboard to my screen.\n\nMy question is, how can I add a newline from the git command line without opening an external program like vi, atom, notepad, word etc...\n\nSince I'm using a unix like system I even tried with pipes (and xargs, the necessary evil) but with something like \"printf \"a\\nb\" | xargs git commit -m\" b gets interpreted as something else. \n\nDoes anybody know of a way to adorn a commit message with newlines in a single git commit command? \nThanks in advance.\n\n\n\n\n"},{"id":"401002","messageId":"xmqqk0zlb3ma.fsf@gitster.c.googlers.com","threadId":"53794","inReplyTo":"17312e90c37.fefa495d137526.1559287962218705021@tomaszubiri.com","subject":"Re: commiting a change from command line with newlines.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-07-03T04:54:05Z","receivedAt":"2020-07-03T04:54:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tomas <correo@tomaszubiri.com> writes:\n\n> I'm trying to write stanzas in my commit message, and naturally\n> the ASCII newline character is the best tool for this, beautifully\n> integrated throughout my whole system, from my keyboard to my\n> screen.\n>\n> My question is, how can I add a newline from the git command line\n> without opening an external program like vi, atom, notepad, word\n> etc...\n\nJust like you pass any command an argument that has newline(s) in\nit, e.g.\n\n    $ git commit -s -m 'area: teach gostak to distim doshes[ENTER]\n    > [ENTER]\n    > Gostaks inherently want to distim doshes, so let them do so[ENTER]\n    > freely.' -a[ENTER]\n\nyou can give such a string to \"git commit\" as an argument to its\n\"-m\" option.\n\n\n\n"},{"id":"401003","messageId":"20200703045544.GD9782@camp.crustytoothpaste.net","threadId":"53794","inReplyTo":"17312e90c37.fefa495d137526.1559287962218705021@tomaszubiri.com","subject":"Re: commiting a change from command line with newlines.","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2020-07-03T04:55:44Z","receivedAt":"2020-07-03T04:55:53Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2020-07-03 at 04:22:09, Tomas wrote:\n> Hello,\n> \n> I'm trying to write stanzas in my commit message, and naturally the ASCII newline character is the best tool for this, beautifully integrated throughout my whole system, from my keyboard to my screen.\n> \n> My question is, how can I add a newline from the git command line without opening an external program like vi, atom, notepad, word etc...\n> \n> Since I'm using a unix like system I even tried with pipes (and xargs, the necessary evil) but with something like \"printf \"a\\nb\" | xargs git commit -m\" b gets interpreted as something else.\n> \n> Does anybody know of a way to adorn a commit message with newlines in a single git commit command?\n\nIt's generally possible to do this with a multi-line string.  You can\nwrite something like this:\n\n$ git commit -m 'git: make boring change\n\nAdd this boring change so that people are put to sleep.  They will be\nable to sleep well and therefore awake refreshed.\n'\n\nYour shell will usually indicate some sort of continuation prompt due to\nthe multi-line string, and you can simply close the single quote when\nyou're done.  This also works in shell scripts, and our testsuite uses\nthis syntax extensively.\n\nIf you need to insert a single quote, you can do this:\n\n$ git commit -m 'git: make boring change\n\nAdd this boring change so that people are put to sleep.  They'\\''ll be\nable to sleep well and therefore awake refreshed.\n'\n\nOf course, the benefit to using an editor is that you can edit your\nchanges, so you may find that while this works, dealing with the\noccasional typing mistake is inconvenient.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"401004","messageId":"20200703051422.GB2450243@alpha","threadId":"53794","inReplyTo":"17312e90c37.fefa495d137526.1559287962218705021@tomaszubiri.com","subject":"Re: commiting a change from command line with newlines.","fromName":"Kevin Daudt","fromEmail":"me@ikke.info","sentAt":"2020-07-03T05:14:22Z","receivedAt":"2020-07-03T05:21:57Z","isPatch":false,"sender":{"key":"me@ikke.info","avatar":"https://avatars.githubusercontent.com/u/135698?v=4"},"body":"On Fri, Jul 03, 2020 at 01:22:09AM -0300, Tomas wrote:\n> Hello,\n> \n> I'm trying to write stanzas in my commit message, and naturally the ASCII newline character is the best tool for this, beautifully integrated throughout my whole system, from my keyboard to my screen.\n> \n> My question is, how can I add a newline from the git command line without opening an external program like vi, atom, notepad, word etc...\n> \n> Since I'm using a unix like system I even tried with pipes (and xargs, the necessary evil) but with something like \"printf \"a\\nb\" | xargs git commit -m\" b gets interpreted as something else. \n> \n> Does anybody know of a way to adorn a commit message with newlines in a single git commit command? \n> Thanks in advance.\n> \n\ngit commit accepts multiple `-m` arguments, where each message will be\nconcattenaed with two newline characters.\n\nSo `git commit -m \"add foo to bar\" -m \"foo is necessary to allow bar to\n...\" -m \"baz would not work in this case because..\"`\n\nWould turn out as:\n\n> add foo to bar\n>\n> foo is necessary to allow bar to...\n>\n> baz would not work in this case beacuse..\n\nHope this helps,\n\nKevin\n"}]}