# git reset --hard include/linux/config.h

5 messages from 2006-07-05 to 2006-07-06. Participants: Sam Ravnborg, Alex Riesen, Junio C Hamano.
Thread: https://gitlist.dev/t/4776

## Sam Ravnborg, 2006-07-05 16:58

Subject: git reset --hard include/linux/config.h
Message-ID: <20060705165801.GA11822@mars.ravnborg.org>
URL: https://gitlist.dev/e/20060705165801.GA11822%40mars.ravnborg.org

```
While working on something unrelated I just did a quick hack
in include/linux/config.h
When done I wanted to get rid of the changes so I did:
git reset --hard include/linux/config.h

And the changes made to include/linux/config.h was indeed gone, with
all the other changes I had in other files.

Now git reset is maybe supposed to work on commit level only, but it
would have been nice if it erroroed out when it saw an argument that
it did not know about. In this case I assume git reset used
"include/linux/config.h" as <commitish>.

Also what is the right command to bring back a file to the original
state after doing some modifications that was not needed anyway?

	Sam

```

## Alex Riesen, 2006-07-05 17:05

Subject: Re: git reset --hard include/linux/config.h
Message-ID: <81b0412b0607051005s59315296tfb68345959a14c1b@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0607051005s59315296tfb68345959a14c1b%40mail.gmail.com
In-Reply-To: <20060705165801.GA11822@mars.ravnborg.org>

```
On 7/5/06, Sam Ravnborg <sam@ravnborg.org> wrote:
> Also what is the right command to bring back a file to the original
> state after doing some modifications that was not needed anyway?

git checkout HEAD include/linux/config.h

```

## Sam Ravnborg, 2006-07-05 17:14

Subject: Re: git reset --hard include/linux/config.h
Message-ID: <20060705171406.GA17834@mars.ravnborg.org>
URL: https://gitlist.dev/e/20060705171406.GA17834%40mars.ravnborg.org
In-Reply-To: <81b0412b0607051005s59315296tfb68345959a14c1b@mail.gmail.com>

```
On Wed, Jul 05, 2006 at 07:05:27PM +0200, Alex Riesen wrote:
> On 7/5/06, Sam Ravnborg <sam@ravnborg.org> wrote:
> >Also what is the right command to bring back a file to the original
> >state after doing some modifications that was not needed anyway?
> 
> git checkout HEAD include/linux/config.h

Thanks!

By the way - the modifications to include/linux/config.h was not lost.
But git apperantly managed to be fooled to think the file was
up-to-date.

	Sam

```

## Alex Riesen, 2006-07-05 17:29

Subject: Re: git reset --hard include/linux/config.h
Message-ID: <81b0412b0607051029q175928faq113b81de8c11db30@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0607051029q175928faq113b81de8c11db30%40mail.gmail.com
In-Reply-To: <20060705171406.GA17834@mars.ravnborg.org>

```
On 7/5/06, Sam Ravnborg <sam@ravnborg.org> wrote:
> On Wed, Jul 05, 2006 at 07:05:27PM +0200, Alex Riesen wrote:
> > On 7/5/06, Sam Ravnborg <sam@ravnborg.org> wrote:
> > >Also what is the right command to bring back a file to the original
> > >state after doing some modifications that was not needed anyway?
> >
> > git checkout HEAD include/linux/config.h
>
> Thanks!
>
> By the way - the modifications to include/linux/config.h was not lost.
> But git apperantly managed to be fooled to think the file was
> up-to-date.

After that checkout or after reset --hard? Both is quiet unusual, though

```

## Junio C Hamano, 2006-07-06 02:45

Subject: Re: git reset --hard include/linux/config.h
Message-ID: <7vhd1va1so.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vhd1va1so.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20060705165801.GA11822@mars.ravnborg.org>

```
Sam Ravnborg <sam@ravnborg.org> writes:

> Now git reset is maybe supposed to work on commit level only, but it
> would have been nice if it erroroed out when it saw an argument that
> it did not know about. In this case I assume git reset used
> "include/linux/config.h" as <commitish>.

There is an attempt to have that check, but obviously it is
busted.  Thanks for noticing.

Maybe something like this is needed instead.

-- >8 --
git-reset: complain and exit upon seeing an unknown parameter.

The check to use "rev-parse --verify" was defeated by the use of
"--default HEAD".  "git reset --hard bogus-committish" just
defaulted to reset to the HEAD without complaining.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/git-reset.sh b/git-reset.sh
index 46451d0..5c02240 100755
--- a/git-reset.sh
+++ b/git-reset.sh
@@ -17,7 +17,11 @@ case "$1" in
         usage ;;
 esac
 
-rev=$(git-rev-parse --verify --default HEAD "$@") || exit
+case $# in
+0) rev=HEAD ;;
+1) rev=$(git-rev-parse --verify "$1") || exit ;;
+*) usage ;;
+esac
 rev=$(git-rev-parse --verify $rev^0) || exit
 
 # We need to remember the set of paths that _could_ be left

```
