Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #77826

Re: basic git operations

From Lawrence D’Oliveiro <ldo@nz.invalid>
Newsgroups comp.os.linux.misc
Subject Re: basic git operations
Date 2025-11-22 21:57 +0000
Organization A noiseless patient Spider
Message-ID <10ftbji$rk22$4@dont-email.me> (permalink)
References <git-20251122190040@ram.dialup.fu-berlin.de> <10ft49n$ii0$1@reader2.panix.com> <dot-20251122210318@ram.dialup.fu-berlin.de>

Show all headers | View raw


On 22 Nov 2025 20:10:58 GMT, Stefan Ram wrote:

>   - They tell you about adding files to the staging area. But for me
>     it was not clear whether this is a copy with all data or just a
>     link to the file in the work tree. Now, the chatbot told me that
>     it's a full copy with all data in the staging area. So, when you
>     later change your work file, it will not be reflected in the
>     staging area without another "add". Of course, as a beginner,
>     next thing you wonder then, is whether this will replace the
>     previous copy in the staging area (I guess so) or be added as a
>     second copy . . .

“git status” will tell you about things like this. E.g. after
modifying a file in a repo:

    ldo@theon:test> git status
    On branch master
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git restore <file>..." to discard changes in working directory)
            modified:   file.fil

    no changes added to commit (use "git add" and/or "git commit -a")

Then I did a “git add -u”, followed by a further edit to the file,
and now git-status reports:

    ldo@theon:test> git status
    On branch master
    Changes to be committed:
      (use "git restore --staged <file>..." to unstage)
            modified:   file.fil

    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git restore <file>..." to discard changes in working directory)
            modified:   file.fil

So you see file.fil appears twice, with the previous edit still in the
index/staging area, with yet another version in the actual source
tree.

Difference between the version in the index, and the last commit:

    ldo@theon:test> git diff --cached
    diff --git a/file.fil b/file.fil
    index b8ab585..9c37b82 100644
    --- a/file.fil
    +++ b/file.fil
    @@ -1 +1 @@
    -One line
    +One lin

Difference between the source tree, and the index:

    ldo@theon:test> git diff
    diff --git a/file.fil b/file.fil
    index 9c37b82..b8ab585 100644
    --- a/file.fil
    +++ b/file.fil
    @@ -1 +1 @@
    -One lin
    +One line

(I know, it’s reverting the previous change.)

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

basic git operations ram@zedat.fu-berlin.de (Stefan Ram) - 2025-11-22 18:08 +0000
  Re: basic git operations Richard Kettlewell <invalid@invalid.invalid> - 2025-11-22 18:33 +0000
    Re: basic git operations ram@zedat.fu-berlin.de (Stefan Ram) - 2025-11-22 18:46 +0000
    Re: basic git operations ram@zedat.fu-berlin.de (Stefan Ram) - 2025-11-22 20:34 +0000
      Re: basic git operations ram@zedat.fu-berlin.de (Stefan Ram) - 2025-11-22 21:13 +0000
      Re: basic git operations Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-22 21:59 +0000
        Re: basic git operations Richard Kettlewell <invalid@invalid.invalid> - 2025-11-22 23:11 +0000
  Re: basic git operations pa@see.signature.invalid (Pierre Asselin) - 2025-11-22 19:52 +0000
    Re: basic git operations ram@zedat.fu-berlin.de (Stefan Ram) - 2025-11-22 20:10 +0000
      Re: basic git operations Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-22 21:57 +0000
      Re: basic git operations Beej Jorgensen <beej@beej.us> - 2025-11-24 20:23 +0000
        Re: basic git operations ram@zedat.fu-berlin.de (Stefan Ram) - 2025-11-24 20:38 +0000
        Re: basic git operations Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-24 23:37 +0000
          Re: basic git operations Beej Jorgensen <beej@beej.us> - 2025-11-25 22:06 +0000
            Re: basic git operations Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-26 00:53 +0000
  Re: basic git operations Pancho <Pancho.Jones@protonmail.com> - 2025-11-22 20:00 +0000
    Re: basic git operations ram@zedat.fu-berlin.de (Stefan Ram) - 2025-11-22 20:19 +0000
      Re: basic git operations Pancho <Pancho.Jones@protonmail.com> - 2025-11-22 20:24 +0000
        Re: basic git operations ram@zedat.fu-berlin.de (Stefan Ram) - 2025-11-22 20:37 +0000
  Re: basic git operations Beej Jorgensen <beej@beej.us> - 2025-11-24 19:51 +0000
    Re: basic git operations Richard Kettlewell <invalid@invalid.invalid> - 2025-11-24 22:27 +0000
      Re: basic git operations Lawrence D’Oliveiro <ldo@nz.invalid> - 2025-11-24 23:41 +0000

csiph-web