
And people probably don’t need to look up the state of a repo at a given snapshot very often. My guess is this list would be come unmanageable pretty quickly. You might be wondering why the dropdown doesn’t show the list of all the possible trees to view. You’ll see that this Tree:ad98b093 commit id matches the id in the far right. What’s a tree? This question gets into the internals of Git, which we will learn together this year! To be honest, all I know right now is that every Git commit has a tree, so this dropdown button label is saying, “show me the files for this commit id.” You’ll also notice that Instead of branch:master or branch:readme-draft, you’re now seeing this Tree:ad98b093 thingy. You’ll see highlighted in the next image a button that displays a tooltip Browse the repository at this point in the history.Ĭlicking on this button takes you back to what looks exactly like the repo homepage, but with one key difference… Now scroll all the way down to the original commit. (If you want to view the state of a repo for a commit on a different branch, use this Branch:master dropwdown button to change to desired branch.)
#Github find file code
Navigate to the Code tab and make sure master is selected. Going back to my random-example repo, suppose you want to see the state of the repo as of the first commit on master. Thus being able to view all the files in a repo for a given commit really helped drive home how Git is so different from other source control systems. I cannot put clothes into a dresser drawer. Always use the -full-history flag for this use case.I’m purely a visual person. History simplification might sometimes be helpful when you're trying to understand how a currently-existing file came to be in its current state, but when trying to track down a file deletion it's more likely to screw you over by hiding the commit you care about. I only looked into the docs and discovered the -full-history flag because git log - some_file was failing for me in a real repository where I was trying to track a deleted file down.

To be clear: this issue isn't merely theoretical. git log -full-history - bar, on the other hand, gives us the commit that created bar and the commit that deleted it. Notice how git log - bar in the terminal dump above resulted in literally no output Git is "simplifying" history down into a fiction where bar never existed. :~/example$ git rm bar & git commit -m "Deleted bar" :~/example$ git rm foo & git commit -m "Deleted foo" :~/example$ touch bar & git add bar & git commit -m "Added bar" :~/example$ touch foo & git add foo & git commit -m "Added foo"ġ file changed, 0 insertions(+), 0 deletions(-) Initialised empty Git repository in /home/mark/example/.git/ Here's a demonstration: :~/example$ git init Is there a risk that git log without -full-history will simply claim that the file was never created? Unfortunately, yes. This is obviously concerning when the file whose history we want is deleted, since the simplest history explaining the final state of a deleted file is no history. Simplest because it prunes some side branches if the end result is the same (i.e. Simplifies the history to the simplest history explaining the final state of the tree. The docs are light on details about exactly how this works and I lack the grit and courage required to try to figure it out from the source code, but the git-log docs have this much to say: Default mode

To see earlier revisions of a specific line, or reblame, click until you've found the changes you're interested in viewing. In the upper-right corner of the file view, click Blame to open the blame view. Click to open the file whose line history you want to view. Without it, Git performs "history simplification" when you ask it for the log of a file. On, navigate to the main page of the repository. The -full-history flag here is important. The last (top) one is the one that deleted the file. Will show you all commits in your repo's history, including merge commits, that touched your_file. Solution 2 Short answer: git log -full-history - your_file See also my article: Which commit deleted a file.

If you want to see only the last commit, which deleted the file, use -1 in addition to the command above. Git log -full-history - shows the changes of a file and works even if the file was deleted.Įxample: git log -full-history.
