Information Technology Reference
In-Depth Information
_M file.txt
7. The file containing Some other info remains unstaged.
How It Works
Recipe 4-10 underlines a very important aspect of the $ git add command. It stages
a file at a given point of time. You can think of $ git add as of special type of $
cp command. Git add command copies the file from the working directory into the sta-
ging area. Of course the operation is performed right after you issue the $ git add com-
mand. If you modify an already staged file your modifications are not automatically
staged. In other words, the version of the file stored in the staging area differs from the
version stored in the working directory. The state like this is indicated by two different
letters, such as:
AM file.txt
The first letter, A , specifies that the file was staged. The second letter, M , tells you
that the file stored in the working directory was modified. How to return the file to a
normal state? If the content that was already staged is important you can follow Recipe
4-10. Otherwise you can redo the $ git add command. The state will become:
A_ file.txt
In that case, changes that were staged and not committed will be lost.
Usually, I do not use states such as AM during my daily work. The reason is very
simple. I do not stage my files and leave them uncommitted. Once the files are staged, I
commit. The only example of using an AM state in a real-life scenario is when I restore
a deleted file from the repository and then—before commit—modify it. Here is the
procedure:
$ git simple-commit lorem
$ git rm lorem
$ git checkout HEAD -- lorem.txt
$ vi lorem.txt
$ git status -s
Search WWH ::




Custom Search