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

Re: Probably typographic error in tutorial 2

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Apr 27, 2025, 21:54 UTC
Message-ID
<CAPig+cSfbW9zG0Jv_t8QLFz6SPHFk=2g-eDirEpX8D0ytNWpXA@mail.gmail.com>
In-Reply-To
<15509dd701ace6793f0ae19368e4c0c3@mail.ntua.gr>
On Sun, Apr 27, 2025 at 5:44 PM el24614 <el24614@mail.ntua.gr> wrote:
Show 5 quoted lines
> I think in tutorial  2 (https://git.scm.com/docs/gittutorial-2) in the
> first code box the second time that file.txt is edited ($ echo 'hello
> world!' >file.txt) there should be an additional ">" because a single
> one will overwrite the contents. As far as i understand from what
> follows bellow, the text should be appended.
Presumably you're talking about this example?
    $ echo 'hello world' > file.txt
    $ git add .
    $ git commit -a -m "initial commit"
    ...
    $ echo 'hello world!' >file.txt
    $ git commit -a -m "add emphasis"

Note that the initial content of `file.txt` is "hello world", whereas the updated content is "hello world!" with trailing exclamation point, so the content of the file does change (indeed, the commit message "add emphasis" hints at the way in which it changes). As such, the example appears to be fine as-is and does not need to be changed to use ">>" instead of ">".

That's not to say the example is ideal since the difference of "!" is potentially difficult to spot. Had it instead been:

    $ echo 'HELLO WORLD' >file.txt

or some other more obvious change, it probably would have been better. Please feel free to submit a patch to improve the documentation if you think such a change would help.

Previous: el24614Next: Junio C Hamano
Message 2 of 3 in “Probably typographic error in tutorial 2”
  1. el24614Apr 27, 2025
  2. Eric SunshineApr 27, 2025
  3. Junio C HamanoApr 28, 2025

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.