Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| git_add_rm [2019/02/28 14:57] – [-f] rpjday | git_add_rm [2019/03/18 12:29] (current) – [-u, --update option] rpjday | ||
|---|---|---|---|
| Line 121: | Line 121: | ||
| < | < | ||
| $ git rm README.asc | $ git rm README.asc | ||
| - | $ git rm -r theme | + | $ git rm -r theme/ |
| </ | </ | ||
| Line 148: | Line 148: | ||
| </ | </ | ||
| - | ===== Advanced "git add" | + | ===== Advanced "git add" |
| - | ==== " | + | ==== " |
| - | Stage all changes and deletions, but not new files: | + | Stage all changes and deletions |
| < | < | ||
| Line 166: | Line 166: | ||
| </ | </ | ||
| - | ==== "-a" ==== | + | ==== "-A", " |
| Stage all changes, additions and deletions: | Stage all changes, additions and deletions: | ||
| Line 183: | Line 183: | ||
| </ | </ | ||
| - | ==== " | + | ==== " |
| Stage changes and additions, but not deletions: | Stage changes and additions, but not deletions: | ||
| Line 200: | Line 200: | ||
| </ | </ | ||
| - | ===== Advanced "git rm" | + | ===== Advanced "git rm" |
| - | ==== " | + | ==== " |
| < | < | ||
| Line 211: | Line 211: | ||
| </ | </ | ||
| - | ==== " | + | ==== " |
| < | < | ||
| Line 225: | Line 225: | ||
| staged in the index, though that default behavior can be | staged in the index, though that default behavior can be | ||
| overridden with the -f option. | overridden with the -f option. | ||
| + | </ | ||
| + | |||
| + | Example: | ||
| + | |||
| + | < | ||
| + | $ git status | ||
| + | On branch master | ||
| + | Your branch is up to date with ' | ||
| + | |||
| + | Changes not staged for commit: | ||
| + | (use "git add < | ||
| + | (use "git checkout -- < | ||
| + | |||
| + | modified: | ||
| + | |||
| + | no changes added to commit (use "git add" and/or "git commit -a" | ||
| + | $ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | $ git rm README.asc | ||
| + | error: the following file has local modifications: | ||
| + | README.asc | ||
| + | (use --cached to keep the file, or -f to force removal) | ||
| + | $ | ||
| + | </ | ||
| + | |||
| + | ==== "git rm" and empty directories ==== | ||
| + | |||
| + | Since Git cannot version empty directories, | ||
| + | |||
| + | ===== Accessing deleted files ===== | ||
| + | |||
| + | ==== Listing all deleted files throughout history ==== | ||
| + | |||
| + | < | ||
| + | $ git log --diff-filter=D --summary | ||
| + | commit 97b26b7710aed5d41a6a079fbc7279e4bc31e1f5 | ||
| + | Author: Adrien Ollier < | ||
| + | Date: Mon Nov 12 12:40:05 2018 +0100 | ||
| + | |||
| + | removed unused images | ||
| + | |||
| + | | ||
| + | | ||
| + | |||
| + | commit 99c2df95f5839f6c6df75eedbfc06cac35389d91 | ||
| + | Author: Adrien Ollier < | ||
| + | Date: Thu Jun 15 12:52:03 2017 +0200 | ||
| + | |||
| + | removed unused images | ||
| + | |||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | ... snip ... | ||
| + | </ | ||
| + | |||
| + | ==== Recovering a deleted file ==== | ||
| + | |||
| + | Display the most recent commit that references the file: | ||
| + | |||
| + | < | ||
| + | $ git log -1 -- OUTLINE.txt | ||
| + | commit b86814bf758645cf1d0ea8a6cbfd1486d257f4dc | ||
| + | Author: Scott Chacon < | ||
| + | Date: Tue Oct 14 10:55:34 2014 +0200 | ||
| + | |||
| + | remove changes notes and initial outline | ||
| + | $ | ||
| + | </ | ||
| + | |||
| + | Now display its content from the // | ||
| + | |||
| + | < | ||
| + | $ git show b86814bf758645cf1d0ea8a6cbfd1486d257f4dc^: | ||
| + | 1. Getting Started | ||
| + | 1.1 About Version Control | ||
| + | * Local Version Control Systems | ||
| + | * Centralized Version Control Systems | ||
| + | * Distributed Version Control Systems | ||
| + | ... snip ... | ||
| + | </ | ||
| + | |||
| + | You can also: | ||
| + | |||
| + | < | ||
| + | $ git rev-list -n 1 HEAD -- OUTLINE.txt | ||
| + | b86814bf758645cf1d0ea8a6cbfd1486d257f4dc | ||
| + | $ | ||
| </ | </ | ||