threads / discuss / 63358

Probably typographic error in tutorial 2

Subject: Probably typographic error in tutorial 2

## tl;dr

3 messages between Apr 27, 2025 and Apr 28, 2025.

replies: 2people: 3as markdown or json

el24614· Apr 27, 2025, 21:02 UTC · lore
Hello,

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.

Kind Regards, N.Antonetsis

Eric Sunshine· Apr 27, 2025, 21:54 UTC · re: el24614 · lore

Re: Probably typographic error in tutorial 2

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.

Junio C Hamano· Apr 28, 2025, 18:37 UTC · re: Eric Sunshine · lore

Re: Probably typographic error in tutorial 2

Eric Sunshine <sunshine@sunshineco.com> writes:
Show 31 quoted lines
> On Sun, Apr 27, 2025 at 5:44 PM el24614 <el24614@mail.ntua.gr> wrote:
>> 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.
Or append "Goodbye world" to pair well with the first sentence?

By the way, I noticed that the URL given in the original post gives a log-in page. IT IS *NOT* the git-scm.com that is associated with this project, but is somebody else.

The URL the original poster meant is probably
    https://git-scm.com/docs/gittutorial-2

I do not think the typo is malicious, though, and scm.com itself is run by folks who have valid reasons to own the domain.

← back to recent threads