git 理解gitk的指南?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1570535/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 07:12:46  来源:igfitidea点击:

Guide to understanding gitk?

gitgitk

提问by krosenvold

I am introducing git to a team of developers and i find gitk to be an amazing tool. It's also quite hard to understand, since understanding gitk requires an understanding of both git history and the viewer tool itself.

我正在向一个开发团队介绍 git,我发现 gitk 是一个了不起的工具。这也很难理解,因为理解 gitk 需要了解 git 历史和查看器工具本身。

Does anyone have any good references to something like a "beginner's guide to git history with gitk" ?

有没有人对诸如“使用 gitk 了解 git 历史的初学者指南”之类的内容有任何好的参考?

回答by Cascabel

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!

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

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 pagesays, gitk takes git-rev-listoptions 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-logbefore, you'll have seen a lot of this.

正如手册页所说,gitk 使用git-rev-list选项来帮助指定应该显示哪些历史记录。这些也可以在“视图”菜单中以交互方式设置。手册页是一个很好的地方,可以找到有关控制视图的方式的更多信息(主要在提交限制部分)。如果你以前看过git-log,你会看到很多这样的。

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!

这里展示了几个常见的 git 瓷器命令,通常处于通用/默认操作模式。列出它们至少可以帮助您找到正确的文档来了解它们的作用,如果您还没有的话!

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

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

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

在分支的上下文菜单中,我们有git-checkout-dgit-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-logparameters: "containing" is --grep, "touching paths" is the arguments, and adding/removing string is -S(pickaxe).

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

  • 前进/后退按钮,行号……显而易见!

  • 找!这里的选项同样是不言自明的,但对于每个人的教育,它们类似于git-log参数:“包含”是--grep,“触摸路径”是参数,添加/删除字符串是-S(镐)。

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:

这里我们有提交消息和 git-diff 的输出 - 这有点像 using git-log -p,还有一点额外的:

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

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

  • “分支”相当于 git branch -a --contains=<commit>

  • "Precedes"/"Follows" 等价于git describe [--contains] <commit>( git-describe)

回答by idursun

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

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

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

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

回答by tishma

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.

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

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.

v.

回答by Davy Landman

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

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

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

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