From 051c9ca5f862823d524e24eafd25269695cbebfe Mon Sep 17 00:00:00 2001 From: tinogomes Date: Tue, 12 Nov 2013 17:15:52 -0200 Subject: [PATCH] new function for git plugin: git_restore_file --- plugins/git/git.plugin.zsh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 505924c64..c47a52af3 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -153,3 +153,16 @@ function work_in_progress() { # these alias commit and uncomit wip branches alias gwip='git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m "wip"' alias gunwip='git log -n 1 | grep -q -c wip && git reset HEAD~1' + +function git_restore_file() { + if [ -z $1 ]; then + echo 'filename required' + return 1 + fi + + local file=$1; shift + + git checkout $(git rev-list -n 1 HEAD -- "$file")~1 -- "$file" + + echo $file +}