理解 gitk 的指南?

发布于 2024-08-08 00:53:37 字数 1539 浏览 12 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

贱人配狗天长地久 2024-08-15 00:53:37

我从来没有见过任何专门针对 gitk 的东西。从“它是如何工作的”的角度来看,这是一个尝试。了解所有内容背后的命令(或至少大致等效)有助于学习更轻松地使用命令行工具,并且还向您展示在文档中查找的位置以更好地理解 gitk!

文件菜单

这在过去的几个主要版本中有所改变 - 我正在描述当前状态。

  • 更新和重新加载:这可能是最令人困惑的事情。重新加载会刷新所有内容,就像您使用相同的配置重新启动程序一样。这意味着如果一个分支已被删除/重新设置基础,如果某些提交现在悬空,您将不再看到它们。另一方面,更新会刷新所有信息,但仍显示之前显示的所有提交。如果您正在进行变基并希望确保没有搞砸,那么这是一个很好的工具 - 您可以看到原始版本和变基版本。

  • 参考文献:非常明显。引用包括标签和分支(可能是远程的)。您可以重读它们,然后列出并单击特定的一个以将其显示在历史记录中。

正如

手册页 所说,gitk 需要 git-rev-list 帮助指定的选项应该展示什么历史。这些也可以在“视图”菜单中交互设置。手册页是查找有关控制视图的方法的更多信息的绝佳位置(主要位于提交限制部分)。如果您之前看过 git-log,您会看到很多这样的内容。

帮助

这里有一个键绑定列表!甜的。

上下文菜单

这呈现了几个常见的 git Ceramic 命令,通常处于常见/默认操作模式下。列出它们至少可以帮助您找到正确的文档来了解它们的用途(如果您还没有)!

  • git-diff (比较此 <- > 选定
  • git-format-patch (打补丁)
  • git-tag (创建标签)
  • git-diff-tree (将提交写入文件,很少使用)
  • git-branch
  • git-cherry-pick
  • git-reset (将分支重置为这里)这会提示您选择软索引、混合索引或硬索引,并简要提醒您每个索引的作用,手册页上有较长的描述,但当然您必须了解索引的概念才能真正理解它。

此时,“标记提交”和相关命令应该是不言自明的。

在分支的上下文菜单中,我们有 git-checkout 和 git-branch 的 -d (删除)模式。

中间部分

  • SHA1 ID:当前提交的哈希值。对于复制/粘贴到终端以对您使用 gitk 查找的给定提交执行操作非常有用。您还可以将哈希值粘贴到此处。

  • 前进/后退按钮,行号...明显!

  • 找到!这里的选项同样是不言自明的,但对于每个人的教育来说,它们类似于 git-log 参数:“containing”为 --grep,“touching paths”为参数,添加/删除字符串为 -S(镐)。

消息/差异窗格

这里我们有提交消息以及 git-diff 的输出 - 这类似于使用 git-log -p ,但有一些额外的内容:

  • “Branches”相当于 < code>gitbranch -a --contains=

  • “Precedes”/“Follows”相当于 git describe [--contains] (git-describe)

I've never seen anything specifically for gitk. Here's a stab at it, from a "how does it work" point of view. Knowing the commands that are behind everything (or at least generally equivalent) helps learn to use command-line tools more easily, and also shows you where to look in documentation to understand gitk better!

File menu

This has changed somewhat over the last few major versions - I'm describing the current state.

  • update and reload: This is probably the most confusing thing. Reload refreshes everything as if you started the program over with the same configuration. This means if a branch has been removed/rebased, if some commits are now dangling, you don't see them anymore. Update, on the other hand, refreshes all the information, but still shows all commits that were previously shown. This is an excellent thing to use if you're rebasing and want to make sure you didn't mess up - you can see both the original and rebased versions.

  • references: pretty obvious. References include tags and branches (which may be remote). You can reread them, and list to click a particular one to show it in the history.

Views

As the man page says, gitk takes git-rev-list options to help specify what history should be shown. These can also be set interactively in the "view" menu. The man page is an excellent place to find more information about the ways you can control views (it's mostly in the commit limiting section). If you've looked at git-log before, you'll have seen a lot of this.

Help

There's a list of keybindings here! Sweet.

Context menu

This presents several common git porcelain commands, generally in a common/default mode of operation. Listing them will at least help you find the right documentation to understand what they do, if you don't already!

The "mark a commit" and related commands should be self-explanatory at this point.

In the context menu for a branch, we have git-checkout and the -d (delete) mode of git-branch.

Middle section

  • SHA1 ID: the hash of the current commit. Very useful for copy/paste into a terminal to perform an action on a given commit you used gitk to find. You can also paste hashes into here.

  • Forward/back buttons, row number... obvious!

  • Find! The options here are again pretty self-explanatory, but for everyone's education, they're analogous to git-log parameters: "containing" is --grep, "touching paths" is the arguments, and adding/removing string is -S (pickaxe).

Message/diff pane

Here we have the commit message along with git-diff's output - this is something like using git-log -p, with a little extra:

  • "Branches" is equivalent to git branch -a --contains=<commit>

  • "Precedes"/"Follows" is equivalent to git describe [--contains] <commit> (git-describe)

最好是你 2024-08-15 00:53:37

这里用截图介绍一下gitk中分支历史的可视化。

http://lostechies.com/joshuaflanagan/2010/ 09/03/使用-gitk-理解-git/

  1. 左上方窗格显示对此存储库的一系列提交,最新的位于顶部。
  2. 已提交 3 项,全部由托尼·斯塔克 (Tony Stark) 完成。
  3. 最近提交的提交消息是“第三次提交”
  4. 有一个本地分支,名为“master”,它指向最近的提交
  5. 有一个远程引用分支:远程存储库中名为“origin”的“master”分支,它也指向最
    最近提交
  6. 顶部提交旁边的黄点表示这是我的工作文件夹中当前的快照(称为 HEAD)
  7. 我突出显示了第二次提交,以便我可以在下部窗格中看到其详细信息
  8. 第二次提交的提交 SHA(唯一标识符,类似于 subversion 修订号)是
    3d024dd9e4a83d8c6a9a143a68b75d4b872115a6
  9. 右下角显示受第二次提交影响的文件列表
  10. 左下角显示提交详细信息,包括完整的差异
  11. 点击右下窗格中的文件会将左下窗格中的差异滚动到相应的第 12 部分。

Here is an introduction to the visualization of branch history in gitk with screenshots.

http://lostechies.com/joshuaflanagan/2010/09/03/use-gitk-to-understand-git/

  1. The upper left pane shows the series of commits to this repository, with the most recent on top.
  2. There have been three commits, all by Tony Stark.
  3. The commit message for the most recent commit was “third commit”
  4. There is a single local branch, named “master’”, it points to the most recent commit
  5. There is a single remote reference branch: the “master” branch from the remote repository named “origin”, it also points to the most
    recent commit
  6. The yellow dot next to the top commit indicates that is the snapshot currently in my working folder (referred to as HEAD)
  7. I’ve highlighted the second commit, so that I can see its details in the lower pane
  8. The commit SHA (unique identifier, similar to subversion revision number) of the second commit is
    3d024dd9e4a83d8c6a9a143a68b75d4b872115a6
  9. The lower right shows the list of files impacted by the second commit
  10. The lower left shows the commit details, including the full diff
  11. Clicking a file in the lower right pane scrolls the diff in the lower left pane to the corresponding section 12.
夜清冷一曲。 2024-08-15 00:53:37

新手真正能用“gitk和历史的结合”来说的是如何通过查看gitk树视图来识别发生了什么的具体解释。

据我所知 - 查看树的正确方法是(当然):

 1. each node is a commit
 2. ultimate parent is at the bottom
 3. direct child to a commit is the one that happened first in the same branch (no matter who did it)
 4. the node with 2 or more children indicates ... ?
 5. merge commit node has 2 parents.
 6. rebase is recognized ... ?

屏幕截图也将受到赞赏。

该树实际上代表了存储库的当前状态。如果我们能够通过查看树视图来判断发生了什么,那就太好了。

谢谢

v。

What novices could really use in terms of "combination of gitk and history" is a specific explanation how to recognize what happened by looking at the gitk tree view.

As far as I got - the right way to look at the tree is (of course):

 1. each node is a commit
 2. ultimate parent is at the bottom
 3. direct child to a commit is the one that happened first in the same branch (no matter who did it)
 4. the node with 2 or more children indicates ... ?
 5. merge commit node has 2 parents.
 6. rebase is recognized ... ?

Screenshots would be appreciated as well.

The tree is actually representing the current state of the repository. What would be great is if we would be able to tell what happened by looking at the tree view.

Thanks

v.

摘星┃星的人 2024-08-15 00:53:37

我发现 gitk 界面唯一有用的是漂亮的(丰富多彩的)分支概述。

如果你想要 git 的 gui,请检查 Windows 上的 TortoiseGit 或 Mac 上的 GitX 或 Linux 上的 QGit。

The only thing I find useful about the gitk interface is the nice (colorful) branches overview..

If you want a gui for git, check TortoiseGit on windows or GitX on Mac or QGit on linux.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文