git - GitHub 能否以补丁的形式显示对一个文件的修改历史?

标签 git version-control github

如果您执行 git log --patch -- path/to/file,您将获得文件的历史记录以及每次提交时对其所做的所有更改的差异,例如这个:

$ 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

我希望能够使用 GitHub 的 Web 界面(而不是命令行) 获得相同类型的格式,并且我想要一个无需代码即可发送给其他人的链接。

最佳答案

以下 URL 将以类似于 git log -p 的格式显示单个文件的所有提交。 :

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

...哪里:

  • <username>是拥有 repo 的人的用户名
  • <project>是 repo 名称
  • <branch>可以是'master'或任何其他分支
  • <path/to/file>希望是不言自明的

(有点)随机选择,这是来自 vim-fugitive repo 的示例.

关于git - GitHub 能否以补丁的形式显示对一个文件的修改历史?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2952507/

相关文章:

GitWeb : Cloning doesn't succeed

git - 时间跟踪+Git : measuring effort per commit

jenkins - 如何将 github webhook 配置到 Google Cloud IAP 背后的 Jenkins 服务器

ubuntu - 没有到主机的路由。 ubuntu 上的 Github( Composer )

github - 如何列出我的要点?

android - 更改本地项目的 bitbucket 存储库名称

git - 我无法在 Windows 7 上通过 Git 登录 heroku

linux - 我怎样才能提取每个 linux 内核提交请求?

visual-studio - 在 Visual Studio 和 Team Foundation Server 中重命名项目文件夹

version-control - 在实时网站上维护备份和修订控制的最佳解决方案是什么?