diff --git a/Readme.md b/Readme.md index 092d705..138956d 100644 --- a/Readme.md +++ b/Readme.md @@ -70,6 +70,7 @@ $ brew install git-extras - `git missing` - `git lock` - `git unlock` + - `git reset-file` ## git-extras @@ -651,3 +652,19 @@ $ git lock config/database.yml ## git-unlock [filename] Unlock a local file `filename` + +## git-reset-file [filename] commit + +Reset one file to `HEAD` or certain commit + +Reset one file to HEAD + +```bash +$ git reset-file .htaccess +``` + +or reset one file to certain commit + +```bash +$ git reset-file .htaccess dc82b19 +``` diff --git a/bin/git-reset-file b/bin/git-reset-file new file mode 100755 index 0000000..c89f843 --- /dev/null +++ b/bin/git-reset-file @@ -0,0 +1,17 @@ +#!/bin/sh + +file="$1" +commit="$2" + +if [[ -f $file ]]; then + git rm --cached -q -f -- $file + if [[ -z $commit ]]; then + git checkout HEAD -- $file + echo "Reset '$1' to HEAD" + else + git checkout $commit -- $file + echo "Reset '$1' to $commit" + fi +else + echo "File '$1' not found in `pwd`" +fi diff --git a/man/git-reset-file.1 b/man/git-reset-file.1 new file mode 100644 index 0000000..6cb6793 --- /dev/null +++ b/man/git-reset-file.1 @@ -0,0 +1,60 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "GIT\-RESET\-FILE" "1" "August 2014" "" "" +. +.SH "NAME" +\fBgit\-reset\-file\fR \- Reset one file +. +.SH "SYNOPSIS" +\fBgit\-reset\-file\fR [] commit\-hash +. +.SH "DESCRIPTION" +Reset one file to HEAD or certain commit\-hash +. +.SH "OPTIONS" + +. +.P +The name of the file to reset\. +. +.P + +. +.P +(Optional) Hash of commit to reset the file to\. Defaults to HEAD\. +. +.SH "EXAMPLES" +Reset one file to HEAD +. +.IP "" 4 +. +.nf + +$ git reset\-file \.htaccess +. +.fi +. +.IP "" 0 +. +.P +or reset one file to certain commit +. +.IP "" 4 +. +.nf + +$ git reset\-file \.htaccess dc82b19 +. +.fi +. +.IP "" 0 +. +.SH "AUTHOR" +Written by Sasha Khamkov <\fIsanusart@gmail\.com\fR> +. +.SH "REPORTING BUGS" +<\fIhttps://github\.com/visionmedia/git\-extras/issues\fR> +. +.SH "SEE ALSO" +<\fIhttps://github\.com/visionmedia/git\-extras\fR> diff --git a/man/git-reset-file.html b/man/git-reset-file.html new file mode 100644 index 0000000..3bd6900 --- /dev/null +++ b/man/git-reset-file.html @@ -0,0 +1,128 @@ + + + + + + git-reset-file(1) - Reset one file + + + + +
+ + + +
    +
  1. git-reset-file(1)
  2. +
  3. +
  4. git-reset-file(1)
  5. +
+ +

NAME

+

+ git-reset-file - Reset one file +

+ +

SYNOPSIS

+ +

git-reset-file [<filename>] commit-hash

+ +

DESCRIPTION

+ +

Reset one file to HEAD or certain commit-hash

+ +

OPTIONS

+ +

<filename>

+ +

The name of the file to reset.

+ +

<commit-hash>

+ +

(Optional) Hash of commit to reset the file to. Defaults to HEAD.

+ +

EXAMPLES

+ +

Reset one file to HEAD

+ +
$ git reset-file .htaccess
+
+ +

or reset one file to certain commit

+ +
$ git reset-file .htaccess dc82b19
+
+ +

AUTHOR

+ +

Written by Sasha Khamkov <sanusart@gmail.com>

+ +

REPORTING BUGS

+ +

<https://github.com/visionmedia/git-extras/issues>

+ +

SEE ALSO

+ +

<https://github.com/visionmedia/git-extras>

+ + +
    +
  1. +
  2. August 2014
  3. +
  4. git-reset-file(1)
  5. +
+ +
+ + diff --git a/man/git-reset-file.md b/man/git-reset-file.md new file mode 100644 index 0000000..bbe9b47 --- /dev/null +++ b/man/git-reset-file.md @@ -0,0 +1,42 @@ +git-reset-file(1) -- Reset one file +================================ + +## SYNOPSIS + +`git-reset-file` [<filename>] commit-hash + +## DESCRIPTION + + Reset one file to HEAD or certain commit-hash + +## OPTIONS + + <filename> + + The name of the file to reset. + + <commit-hash> + + (Optional) Hash of commit to reset the file to. Defaults to HEAD. + +## EXAMPLES + + Reset one file to HEAD + + $ git reset-file .htaccess + + or reset one file to certain commit + + $ git reset-file .htaccess dc82b19 + +## AUTHOR + +Written by Sasha Khamkov <> + +## REPORTING BUGS + +<> + +## SEE ALSO + +<> diff --git a/man/index.txt b/man/index.txt index 68b4fbe..1251044 100644 --- a/man/index.txt +++ b/man/index.txt @@ -1,5 +1,6 @@ # manuals git-alias(1) git-alias +git-archive-file(1) git-archive-file git-back(1) git-back git-bug(1) git-bug git-changelog(1) git-changelog @@ -14,19 +15,25 @@ git-delete-tag(1) git-delete-tag git-effort(1) git-effort git-extras(1) git-extras git-feature(1) git-feature +git-fork(1) git-fork git-fresh-branch(1) git-fresh-branch git-gh-pages(1) git-gh-pages git-graft(1) git-graft git-ignore(1) git-ignore git-info(1) git-info git-local-commits(1) git-local-commits +git-lock(1) git-lock +git-missing(1) git-missing +git-rebase-patch(1) git-rebase-patch git-refactor(1) git-refactor git-release(1) git-release git-rename-tag(1) git-rename-tag git-repl(1) git-repl +git-reset-file(1) git-reset-file git-setup(1) git-setup git-show-tree(1) git-show-tree git-squash(1) git-squash git-summary(1) git-summary git-touch(1) git-touch git-undo(1) git-undo +git-unlock(1) git-unlock