Hi Uwe,

On 21/11/2019 08:44, Uwe Brauer wrote:
"PO" == Philip Oakley <philipoakley@iee.email> writes:
HI Philip


    > Hi Uwe,

[Snip]...


    > So in Git, you can add 'everything', a few things, or even pick lines from
    > files, for each commit, leaving the worktree (real filesystem content)
    > distinct from the 'staging area/index' (equivalent to the old fashioned
    > outbox on your desk-top ready to summon a clerk to 'file'[commit] it's
    > contents).

    > It's disadvantage is that most modern folks don't have the mental model or
    > imagery in their heads to know what to do, and the Git documentation is
    > very poor at describing these mental model things.

Tanks for the detailed answer. Let me try to reword it.

     1. I have a registered file in git.

     2. I do a lot of changes in different   lines.

     3. So I can commit either all of them or just some parts.
using the `git add -p` (--patch) style is the part that allows you to (from man page):

   Interactively choose hunks of patch between the index and the work
   tree and add them to the index. This gives the user a chance to
   review the difference before adding modified contents to the index.


     4. The command git add . Tells git to use them all,
It (`.`) says use all _files_, you could also still include the `-p` optionĀ  to select chunks from all those changed files. Or use the `-- <path>` to just select one file path (with or without `-p`)

     5. then git commit -m   "my changes" will in fact commit them all. Is this 
correct?
If you used the simple `git add .` then yes.
As noted, git gives you a lot of rope (options) to confuse yourself with [it is a maze of flexibility!].


If so I must say that the wording is not optimal. I thought add is for
adding files not commits.
"add" is for adding files, chunks and hunks to the staging area (a/k/a "Index"), in readiness for committing the Staging area/Index content into the repo (*)

Mercurial has the same behavior, as the one described above, only the other way 
around.


    hg commit -m "my changes"
    will per default commit everything. If I want to pick only some
    changes I have to run
It's the change of the default expectation that can catch folk out ..
    hg commit -i

Uwe
Philip
(*) a further subtlety is that "the repo" is not quite the same as "the object store". Often temporary items/aretfacts will be stored as objects in the store, and accessed via their hash value/name. The "Index" is a set of pointers to those artefact hash values, while "the repo" is again a set of linked pointers also into the object store. Those 'repo' pointers are from the branch refs/heads and HEAD etc. Git does a lot of this half way, half-a-step, abstraction where the logical item and the physical item can easily be confused (e.g. branches are simply files in a nix filesystem using the nix dir/dir/file nomenclature as a cheat! ...

--
You received this message because you are subscribed to the Google Groups "Git for 
human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/9b0f6126-7d9c-1e1b-20af-776bf517f25b%40iee.email.

Reply via email to