Lifecycle of a Git file
A file in git goes through the following stages:
git add puts a snapshot of the file to the staging area.
Further modification to the file will not be committed with git commit unless a git add is done again.
git diff compares local file to the staged file.
git diff --staged compares staged file to the committed file.
=> if you have staged all your changes, then git diff will give no output but git diff -- staged will show you all the changes.
Removing a filerm foo
git rm foo
git commit foo
If you accidentally staged a file, it can be removed from the staging area by
git rm --cahced foo
This keeps the file in your local directory but removes it from staging area.
Moving a filegit mv src.txt dest.txt
git considers moving a file as renaming a file.
This is useful because the file history is preserved on rename.
|Email:||(Your email is not shared with anybody)|