Home > other >  Is that possible to see a file in a specific commit from Github desktop locally than the difference?
Is that possible to see a file in a specific commit from Github desktop locally than the difference?

Time:12-31

In Gitlab/Github, if I use it remotely, I can download a file in a specific commit, by going to the commits and browser the repository at that commit.

If I use the Github desktop on windows with the repository on my PC (not push it to the remote), I tried to see a specific commit, I only find the difference of versions. But nowhere to see the entire file at that specific commit. Is there any method for doing it?

CodePudding user response:

This is followed by desktop/desktop issue 6535 (for binary file, or any other type actually)

From 2019:

The biggest problem here is that while we can easily display the diff of changes in a repository, opening a specific version of a file is not easy - either we'd need to checkout that commit so the working directory has that version, or we extract the specific version of the file to a temporary location, which the default program can then open.

Here's a rough flow I can think of that might achieve this:

  • In "History" view, find a commit with an older version of the file you're interested in opening
  • When the user clicks to perform the action, Desktop will extract the blob from the repository to the OS temporary directory, using a pattern like {SHA}-{filename} so that we can avoid clashes if the user looks at multiple versions of a file
  • Once that file exists on disk, perform the existing behaviour of opening this new file in the default program

In command-line, you could use git show REVISION:path/to/file or git cat-file -p <sha1>:./file.tex > wherever.tex.

In your case:

cd /mnt/c/Users/user/Documents/GitHub/test-b
git show e39...:test-b/1.txt

Meaning: the path in git show should be the one from the root folder of the repository, not the OS full path.

The OP Redzeń confirms in the comments:

cd  test-b, 
# pwd: /mnt/c/Users/user/Documents/GitHub/test-b/test-b
git show e39...:1.txt
  • Related