Working Directory, Staging Area, and Repository

0

(a) The working directory contains the files that are not handled by git. These files are also referred to as "untracked files."
(b) Staging area contains the files that are going to be a part of the next commit, which lets git know what changes in the file are going to occur for the next commit.
(c) The repository contains all of a project's commits.

  • git add adds the file[s] from (1) to (2)
  • git commit moves/tracks the files from (2) to (3)
~/code/gitfaffing % git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   world.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    orphan.txt

no changes added to commit (use "git add" and/or "git commit -a")
~/code/gitfaffing % git add world.txt 
~/code/gitfaffing % git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   world.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    orphan.txt

~/code/gitfaffing % git add .
~/code/gitfaffing % git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   orphan.txt
    modified:   world.txt

~/code/gitfaffing % git commit -a -m "welcome orphan"
dquote> "
[master 67642d8] welcome orphan
 2 files changed, 2 insertions(+), 1 deletion(-)
 create mode 100644 orphan.txt
~/code/gitfaffing % git status
On branch master
nothing to commit, working tree clean

~/code/gitfaffing % git log --oneline               
67642d8 (HEAD -> master) welcome orphan
e4ed093 even better edit of world.txt
be880c6 added world.txt and edited hello.txt
aa1a9d2 init

  • 0 posts
  • 0 subtopics
  • 6 days ago by vince