threads / discuss / 23338

Mysterious junk in file.... "not commited yet"

Subject: Mysterious junk in file.... "not commited yet"

## tl;dr

6 messages between Apr 5, 2010 and Apr 5, 2010.

replies: 5people: 3as markdown or json

Howard Miller· Apr 5, 2010, 18:13 UTC · lore
Hi,

I just found a file in my project that has "junk" at the beginning (looks like some binary stuff at the start of a php file). Git status and diff show nothing unusual (nothing to commit). Git log shows nothing I wouldn't expect and show 'shows' show noting. Git blame on the other shows the offending line as 'not commited yet'. I tried doing 'git checkout <filename>' but it didn't fix it.

What am I missing? Has git broken somewhere?
Thanks,
Howard
Avery Pennarun· Apr 5, 2010, 18:52 UTC · re: Howard Miller · lore

Re: Mysterious junk in file.... "not commited yet"

On Mon, Apr 5, 2010 at 2:13 PM, Howard Miller <howard@e-learndesign.co.uk> wrote:

Show 8 quoted lines
> I just found a file in my project that has "junk" at the beginning
> (looks like some binary stuff at the start of a php file). Git status
> and diff show nothing unusual (nothing to commit). Git log shows
> nothing I wouldn't expect and show 'shows' show noting. Git blame on
> the other shows the offending line as 'not commited yet'. I tried
> doing 'git checkout <filename>' but it didn't fix it.
>
> What am I missing? Has git broken somewhere?
You might have 'git add'ed the changed line.  Try this:
   git checkout HEAD -- <filename>
Have fun,
Avery
Howard Miller· Apr 5, 2010, 19:03 UTC · re: Avery Pennarun · lore

Re: Mysterious junk in file.... "not commited yet"

Show 9 quoted lines
>
> You might have 'git add'ed the changed line.  Try this:
>
>   git checkout HEAD -- <filename>
>
> Have fun,
>
> Avery
>

Hmmm... fixed. I've never even heard of 'git add' before. Why is this different to plain old 'checkout' without the HEAD?

Anyway... thanks. Day saved :)
Avery Pennarun· Apr 5, 2010, 19:13 UTC · re: Howard Miller · lore

Re: Mysterious junk in file.... "not commited yet"

On Mon, Apr 5, 2010 at 3:03 PM, Howard Miller <howard@e-learndesign.co.uk> wrote:

Show 8 quoted lines
>> You might have 'git add'ed the changed line.  Try this:
>>
>>   git checkout HEAD -- <filename>
>
> Hmmm... fixed. I've never even heard of 'git add' before. Why is this
> different to plain old 'checkout' without the HEAD?
>
> Anyway... thanks. Day saved :)

That ends up being a very long story. You should probably read about "staging" files in git in a git tutorial somewhere. :)

Glad I could help.
Have fun,
Avery
Matthieu Moy· Apr 5, 2010, 19:24 UTC · re: Howard Miller · lore

Re: Mysterious junk in file.... "not commited yet"

Howard Miller <howard@e-learndesign.co.uk> writes:
> Hmmm... fixed. I've never even heard of 'git add' before.
Hmm, maybe it's time to read the manual, then ;-).
> Why is this different to plain old 'checkout' without the HEAD?

Read about the "index" of Git, aka "staging area". It's where Git (and you) prepare commit, and "git diff" shows you the diff against it. Plain "git checkout" will read from the index, while "git checkout HEAD" takes the last commited version.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Howard Miller· Apr 5, 2010, 19:29 UTC · re: Matthieu Moy · lore

Re: Mysterious junk in file.... "not commited yet"

> Plain "git checkout" will read from the index, while "git checkout
> HEAD" takes the last commited version.

Cool.... that's the bit I hadn't appreciated. I was (falsely) under the impression that 'git checkout' grabbed the last committed version. Suitably educated... thanks!

← back to recent threads