1
0
mirror of https://github.com/namibia/tips.git synced 2024-11-16 18:15:19 +00:00

Grab a file from a stash. Restore file as per a commit hash

This commit is contained in:
Samar Panda 2016-02-12 23:40:59 +05:30
parent 90d98ea980
commit c42e1547ab
2 changed files with 25 additions and 0 deletions

View File

@ -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 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) * [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) * [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 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 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) * [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) * [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) * [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 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) * [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) * [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) * [Make git case sensitive.](https://github.com/git-tips/tips#make-git-case-sensitive)
@ -331,6 +333,17 @@ __Alternatives:__
git stash drop <stash@{n}> git stash drop <stash@{n}>
``` ```
## Grab a single file from a stash
```sh
git checkout <stash@{n}> -- <file_path>
```
__Alternatives:__
```sh
git checkout stash@{0} -- <file_path>
```
## Show all tracked files ## Show all tracked files
```sh ```sh
git ls-files -t git ls-files -t
@ -527,6 +540,11 @@ git clean -X -f
git checkout <deleting_commit>^ -- <file_path> git checkout <deleting_commit>^ -- <file_path>
``` ```
## Restore file to a specific commit-hash
```sh
git checkout <commit-ish> -- <file_path>
```
## Always rebase instead of merge on pull. ## Always rebase instead of merge on pull.
```sh ```sh
git config --global branch.autosetuprebase always git config --global branch.autosetuprebase always

View File

@ -125,6 +125,10 @@
"title": "Delete all stored stashes", "title": "Delete all stored stashes",
"tip": "git stash clear", "tip": "git stash clear",
"alternatives": ["git stash drop <stash@{n}>"] "alternatives": ["git stash drop <stash@{n}>"]
}, {
"title": "Grab a single file from a stash",
"tip": "git checkout <stash@{n}> -- <file_path>",
"alternatives": ["git checkout stash@{0} -- <file_path>"]
}, { }, {
"title": "Show all tracked files", "title": "Show all tracked files",
"tip": "git ls-files -t" "tip": "git ls-files -t"
@ -228,6 +232,9 @@
}, { }, {
"title": "Restore deleted file.", "title": "Restore deleted file.",
"tip": "git checkout <deleting_commit>^ -- <file_path>" "tip": "git checkout <deleting_commit>^ -- <file_path>"
}, {
"title": "Restore file to a specific commit-hash",
"tip": "git checkout <commit-ish> -- <file_path>"
}, { }, {
"title": "Always rebase instead of merge on pull.", "title": "Always rebase instead of merge on pull.",
"tip": "git config --global branch.autosetuprebase always" "tip": "git config --global branch.autosetuprebase always"