Re: [git-users] Looking for a change to a file

2015-09-14 Thread Philip Oakley

From: "Michael" 
I've got a file, with a diff/change, that I thought had already been 
checked into a previous commit. I want to see if this change exists in 
any checkin of that file.


Is there any way to ask for "all the checked-in versions of file X"? 
As far as I know, git only knows files by their sha hashes, and not by 
names -- which already tells me that there's probably something that I 
really don't understand about git.




Git does know about file names. but it keeps them separately from the 
content.


The content is the 'blob', each with it's own sha1, and identical 
content sharing the same sha1 blob (thing of all the COPYING and LICENCE 
files with identical content).


The filenames themselves is kept in the object called a 'tree' 
(conceptually similar to directory), and it lists all the [file]names to 
be used and the sha1's of their contents.


The tree can not only list the tracked files in a directory, but also 
list other trees (sub-directories) in the classic heirarchy.


A commit object lists just one tree as the sum total of the tracked 
files/dirs, along with the message and sha1's of the parent(s).



So, Git can search can search all the files at all of the revisions 
within the repo given the right command. e.g 'git grep'.

--
Philip 


--
You received this message because you are subscribed to the Google Groups "Git for 
human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Looking for a change to a file

2015-09-13 Thread Charles Manning
When you're trying to find why a specific change was made, then git blame
is also your friend.

On Mon, Sep 14, 2015 at 7:16 AM, Paul Smith  wrote:

> On Sun, 2015-09-13 at 11:32 -0700, Michael wrote:
> > I've got a file, with a diff/change, that I thought had already been
> > checked into a previous commit. I want to see if this change exists in
> > any checkin of that file.
> >
> > Is there any way to ask for "all the checked-in versions of file X"?
> > As far as I know, git only knows files by their sha hashes, and not by
> > names -- which already tells me that there's probably something that I
> > really don't understand about git.
>
> Git doesn't know files by SHA hashes.  Git knows "a set of changes to
> one or more files" by its SHA hash.  The SHA hash names the _commit_ not
> a specific file.
>
> However, if you want to see the commits that impacted a given file it's
> trivial:
>
>   git log 
>
> If you want to see the commits that impacted any file in a subdirectory
> that's trivial as well:
>
>   git log 
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Git for human beings" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to git-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Looking for a change to a file

2015-09-13 Thread Paul Smith
On Sun, 2015-09-13 at 11:32 -0700, Michael wrote:
> I've got a file, with a diff/change, that I thought had already been
> checked into a previous commit. I want to see if this change exists in
> any checkin of that file.
> 
> Is there any way to ask for "all the checked-in versions of file X"?
> As far as I know, git only knows files by their sha hashes, and not by
> names -- which already tells me that there's probably something that I
> really don't understand about git.

Git doesn't know files by SHA hashes.  Git knows "a set of changes to
one or more files" by its SHA hash.  The SHA hash names the _commit_ not
a specific file.

However, if you want to see the commits that impacted a given file it's
trivial:

  git log 

If you want to see the commits that impacted any file in a subdirectory
that's trivial as well:

  git log 


-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[git-users] Looking for a change to a file

2015-09-13 Thread Michael
I've got a file, with a diff/change, that I thought had already been checked 
into a previous commit. I want to see if this change exists in any checkin of 
that file.

Is there any way to ask for "all the checked-in versions of file X"? As far as 
I know, git only knows files by their sha hashes, and not by names -- which 
already tells me that there's probably something that I really don't understand 
about git.

---
Entertaining minecraft videos
http://YouTube.com/keybounce

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [git-users] Looking for a change to a file

2015-09-13 Thread Magnus Therning
On Sun, Sep 13, 2015 at 03:16:21PM -0400, Paul Smith wrote:
> On Sun, 2015-09-13 at 11:32 -0700, Michael wrote:
> > I've got a file, with a diff/change, that I thought had already been
> > checked into a previous commit. I want to see if this change exists in
> > any checkin of that file.
> > 
> > Is there any way to ask for "all the checked-in versions of file X"?
> > As far as I know, git only knows files by their sha hashes, and not by
> > names -- which already tells me that there's probably something that I
> > really don't understand about git.
> 
> Git doesn't know files by SHA hashes.  Git knows "a set of changes to
> one or more files" by its SHA hash.  The SHA hash names the _commit_ not
> a specific file.
> 
> However, if you want to see the commits that impacted a given file it's
> trivial:
> 
>   git log 
> 
> If you want to see the commits that impacted any file in a subdirectory
> that's trivial as well:
> 
>   git log 

For easy viewing of both log and the actual diffs I can recommend the
tool `tig`:

tig 

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Unreadable code,
Why would anyone use it?
Learn a better way.
 -- Geoff Kuenning's contribution to the 2004 Perl Haiku Contest,
Haikus about Perl - 'Dishonerable Mention' winner

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.