Can GitHub show the history of changes made to a single file in the form of a patch?

If you run git log --patch -- path/to/file , you will get the file history along with the difference of all the changes made to it with each commit, for example:

 $ git log --patch -- git-rebase.sh commit 20351bb06bf4d32ef3d1a6849d01636f6593339f Author: Ramkumar Ramachandra <artagnon@gmail.com> Date: Sat Jun 15 18:43:26 2013 +0530 rebase: use 'git stash store' to simplify logic rebase has no reason to know about the implementation of the stash. In the case when applying the autostash results in conflicts, replace the relevant code in finish_rebase () to simply call 'git stash store'. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> diff --git a/git-rebase.sh b/git-rebase.sh index d0c11a9..17be392 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -153,11 +153,8 @@ finish_rebase () { then echo "$(gettext 'Applied autostash.')" else - ref_stash=refs/stash && - >>"$GIT_DIR/logs/$ref_stash" && - git update-ref -m "autostash" $ref_stash $stash_sha1 || - die "$(eval_gettext 'Cannot store $stash_sha1')" - + git stash store -m "autostash" -q $stash_sha1 || + die "$(eval_gettext "Cannot store \$stash_sha1")" gettext 'Applying autostash resulted in conflicts. Your changes are safe in the stash. You can run "git stash pop" or "git stash drop" it at any time. commit 2e6e276decde2a9f04fc29bce734a49d3ba8f484 Author: Ramkumar Ramachandra <artagnon@gmail.com> Date: Fri Jun 14 18:47:52 2013 +0530 rebase: use peel_committish() where appropriate The revisions specified on the command-line as <onto> and <upstream> arguments could be of the form :/quuxery; so, use peel_committish() to resolve them. The failing tests in t/rebase and t/rebase-interactive now pass. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> diff --git a/git-rebase.sh b/git-rebase.sh index d0c11a9..6987b9b 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -434,7 +434,7 @@ then shift ;; esac - upstream=`git rev-parse --verify "${upstream_name}^0"` || + upstream=$(peel_committish "${upstream_name}") || die "$(eval_gettext "invalid upstream \$upstream_name")" upstream_arg="$upstream_name" else @@ -470,7 +470,7 @@ case "$onto_name" in fi ;; *) - onto=$(git rev-parse --verify "${onto_name}^0") || + onto=$(peel_committish "$onto_name") || die "$(eval_gettext "Does not point to a valid commit: \$onto_name")" ;; esac 

I want to have the same format using the GitHub web interface (not from the command line) , and I want the link to be sent to someone else without code.

+85
git version-control github
Jun 01 '10 at 19:06
source share
4 answers

The following URL will display all commits for a single file in a format similar to git log -p :

http://github.com/<username>/<project>/commits/<branch>/<path/to/file>

... where:

  • <username> is the name of the user who owns the repo
  • <project> is the repo name
  • <branch> can be a "master" or any other branch
  • <path/to/file> hopefully will be clear

The selection is (somewhat) random, here is an example from vim-fugitive repo .

+80
Jun 01 '10 at 19:14
source share

Based on the answers above and my own attempts to find this exact function, the correct answer to this question seems to be: no .

Edit: Before you vote, try to prove that I'm wrong. Sometimes the right answer is not what you want to hear.

+44
Nov 02 '15 at
source share

An alternative to directly responding to a URL (which BTW is perfectly correct) using the GitHub interface:

  • Click View Source
  • Switch to the desired branch
  • Look for the file you want until you get the actual source view for the file
  • Click "history" in the upper right corner.
+34
Jun 04 '10 at 20:30
source share

If you are on Linux, install TIG as:

sudo apt-get install tig

and then

tig path / to / file /

It will show you all the commits and their corresponding changes.

Talat Parvez

-3
Feb 20 '16 at 20:06
source share



All Articles