diff --git a/README.md b/README.md index 0936ad2..557387b 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,13 @@ * [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) * [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) @@ -75,6 +77,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 +334,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 @@ -356,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 @@ -527,6 +552,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..0e0d6be 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" @@ -140,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" @@ -228,6 +236,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"