----- Original Message ----- 
  From: Sharan Basappa 
  To: Git for human beings 
  Sent: Friday, May 20, 2016 7:16 PM
  Subject: [git-users] Git life cycle


  Folks,


  Git mentions that state of the file as untracked, unmodified, modified and 
staged.


  As I understand untracked files are not yet in the respository.
  unmodified and modified is understood but what action results in a file being 
in staged state?
  is it git add or git commit?


  Thanks, 
Git does take a little while to grasp, which is because of the shift from a 
centralised store to a distributed storage and control method.

Git holds a local state file called the Index, also called the staging area, 
that helps mediate your movement of updated files from your local file system 
(the work tree) into the repository.

An untracked file, at a particular path in your work tree is one that you 
haven't given to Git or it's Index to track. (you can also explicitly tell Git 
which files to ignore)

If you decide that you want to store the contents of a file in the repository, 
first you add it to the Index, that is, it is staged [i.e. the file is ready 
for formal despatch to the repository]. 

If a file had already been stored in the repository previously, then it would 
be considered unmodified. If you had changed the file from it's previously 
stored content, then it would have be 'modified', but note that you haven't yet 
added it to the index. If you add it, then it becomes staged, rather than 
modified. If you continue changing it you get that it's modified again, and 
there is that staged copy in the index.

Once you have all the right content in the Index you can commit that package of 
changed files. At that point your staged files will revert to being labelled 
unmodified, though if you had a modified file in the work tree it would still 
be modified. This can be confusing at first but is quite powerful when needed. 

It is worth look for the various git books and explanations of the git 
internals. Which one works for you will depend on your interests (e.g. 
programmer vs computer scientist ;-)

Philip

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to