From c42e1547abcc823db3b505cafc28f3074f75a9b0 Mon Sep 17 00:00:00 2001 From: Samar Panda Date: Fri, 12 Feb 2016 23:40:59 +0530 Subject: [PATCH 1/2] Grab a file from a stash. Restore file as per a commit hash --- README.md | 18 ++++++++++++++++++ tips.json | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index 0936ad2..9a4d53d 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ * [Apply any stash without deleting from the stashed list](https://github.com/git-tips/tips#apply-any-stash-without-deleting-from-the-stashed-list) * [Apply last stashed state and delete it from stashed list](https://github.com/git-tips/tips#apply-last-stashed-state-and-delete-it-from-stashed-list) * [Delete all stored stashes](https://github.com/git-tips/tips#delete-all-stored-stashes) +* [Grab a single file from a stash](https://github.com/git-tips/tips#grab-a-single-file-from-a-stash) * [Show all tracked files](https://github.com/git-tips/tips#show-all-tracked-files) * [Show all untracked files](https://github.com/git-tips/tips#show-all-untracked-files) * [Show all ignored files](https://github.com/git-tips/tips#show-all-ignored-files) @@ -75,6 +76,7 @@ * [Undo assume-unchanged.](https://github.com/git-tips/tips#undo-assume-unchanged) * [Clean the files from `.gitignore`.](https://github.com/git-tips/tips#clean-the-files-from-gitignore) * [Restore deleted file.](https://github.com/git-tips/tips#restore-deleted-file) +* [Restore file to a specific commit-hash](https://github.com/git-tips/tips#restore-file-to-a-specific-commit-hash) * [Always rebase instead of merge on pull.](https://github.com/git-tips/tips#always-rebase-instead-of-merge-on-pull) * [List all the alias and configs.](https://github.com/git-tips/tips#list-all-the-alias-and-configs) * [Make git case sensitive.](https://github.com/git-tips/tips#make-git-case-sensitive) @@ -331,6 +333,17 @@ __Alternatives:__ git stash drop ``` +## Grab a single file from a stash +```sh +git checkout -- +``` + + +__Alternatives:__ +```sh +git checkout stash@{0} -- +``` + ## Show all tracked files ```sh git ls-files -t @@ -527,6 +540,11 @@ git clean -X -f git checkout ^ -- ``` +## Restore file to a specific commit-hash +```sh +git checkout -- +``` + ## Always rebase instead of merge on pull. ```sh git config --global branch.autosetuprebase always diff --git a/tips.json b/tips.json index 45f147a..ff48dad 100644 --- a/tips.json +++ b/tips.json @@ -125,6 +125,10 @@ "title": "Delete all stored stashes", "tip": "git stash clear", "alternatives": ["git stash drop "] +}, { + "title": "Grab a single file from a stash", + "tip": "git checkout -- ", + "alternatives": ["git checkout stash@{0} -- "] }, { "title": "Show all tracked files", "tip": "git ls-files -t" @@ -228,6 +232,9 @@ }, { "title": "Restore deleted file.", "tip": "git checkout ^ -- " +}, { + "title": "Restore file to a specific commit-hash", + "tip": "git checkout -- " }, { "title": "Always rebase instead of merge on pull.", "tip": "git config --global branch.autosetuprebase always" From e416adc1ff51abecb14fd6ccd279661e41126c47 Mon Sep 17 00:00:00 2001 From: Samar Panda Date: Fri, 12 Feb 2016 23:56:56 +0530 Subject: [PATCH 2/2] Untrack files without deleting --- README.md | 12 ++++++++++++ tips.json | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/README.md b/README.md index 9a4d53d..557387b 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ * [Show all ignored files](https://github.com/git-tips/tips#show-all-ignored-files) * [Create new working tree from a repository (git 2.5)](https://github.com/git-tips/tips#create-new-working-tree-from-a-repository-git-25) * [Create new working tree from HEAD state](https://github.com/git-tips/tips#create-new-working-tree-from-head-state) +* [Untrack files without deleting](https://github.com/git-tips/tips#untrack-files-without-deleting) * [Before deleting untracked files/directory, do a dry run to get the list of these files/directories](https://github.com/git-tips/tips#before-deleting-untracked-filesdirectory-do-a-dry-run-to-get-the-list-of-these-filesdirectories) * [Forcefully remove untracked files](https://github.com/git-tips/tips#forcefully-remove-untracked-files) * [Forcefully remove untracked directory](https://github.com/git-tips/tips#forcefully-remove-untracked-directory) @@ -369,6 +370,17 @@ git worktree add -b git worktree add --detach HEAD ``` +## Untrack files without deleting +```sh +git rm --cached +``` + + +__Alternatives:__ +```sh +git rm --cached -r +``` + ## Before deleting untracked files/directory, do a dry run to get the list of these files/directories ```sh git clean -n diff --git a/tips.json b/tips.json index ff48dad..0e0d6be 100644 --- a/tips.json +++ b/tips.json @@ -144,6 +144,10 @@ }, { "title": "Create new working tree from HEAD state", "tip": "git worktree add --detach HEAD" +}, { + "title": "Untrack files without deleting", + "tip": "git rm --cached ", + "alternatives": ["git rm --cached -r "] }, { "title": "Before deleting untracked files/directory, do a dry run to get the list of these files/directories", "tip": "git clean -n"