您可以使用 TortoiseGit 与索引/暂存区域进行交互吗?

发布于 2024-11-08 01:43:17 字数 749 浏览 0 评论 0原文

我的任务是向我的同事做关于 Git 的演示,他们几乎都是习惯使用 TortoiseCVS 的 Windows 用户。我已经使用 Git 大约一年了,但我几乎只使用 Unix 命令行界面。

所以我一直在尝试熟悉 Windows GUI Git 工具,包括 TortoiseGit。但在我看来,这不仅仅是 Git 命令行界面上的 GUI 皮肤,而且实际上完全抽象了一些东西,特别是索引。

例如,当我在 Windows 资源管理器中右键单击一个新的、未版本控制的文件时,我可以从 TortoiseGit 菜单中选择“添加”,然后提交该文件,但是 Git 中已有的文件缺少相同的菜单项,在这种情况下,我只看到选项“子模块添加”。

没有办法用 TortoiseGit 与索引交互吗?

具体来说,我正在寻找 git add 、 git diff --cached 和 git reset HEAD 的类似物。

这里向 Google 小组发送的有关此事的消息,但那是去年夏天的消息。

我正在使用 TortoiseGit 版本 1.6.5.0 和 msysgit 版本 1.7.4.msysgit.0(如果有的话)。我几天前安装了这些,所以它们可能是最新的。

I've been tasked with giving a presentation on Git to my colleagues, who are almost entirely Windows users who are used to using TortoiseCVS. I've been using Git for about a year, but I almost exclusively used the Unix command line interface.

So I've been trying to get familiar with the Windows GUI Git tools including TortoiseGit. But it seems to me that this is more than just GUI skin over the Git command line interface, and actually abstract some things completely away, specifically the index.

For instance, when I right click a new, unversioned file in the Windows Explorer, I can select "Add" from the TortoiseGit menu, and later commit this file, but this same menu item is missing from files which are already in Git, in which case I only see the option "submodule add".

Is there no way to interact with the index with TortoiseGit?

I'm looking for analogues to git add, git diff --cached, and git reset HEAD, specifically.

Here's a message to the Google group about this, but it was from last summer.

I'm using TortoiseGit version 1.6.5.0 and msysgit version 1.7.4.msysgit.0, if it matters. I installed these just a few days ago so they are probably reasonably up to date.

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

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

发布评论

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

评论(4

横笛休吹塞上声 2024-11-15 01:43:17

答案是:不,你不能

对我来说,TortoiseGit 是一个工具,您可以使用它来更轻松地从 CVS 转换到 Git(就像我在 TortoiseGit 真的让 Git 成为像 TortoiseSVN 一样更容易使用?)。但是,一旦完成过渡并且您的同事对 Git 更加熟悉,就该拿出真正的工具了。

与 Git 交互最强大的工具是命令行。时期。 Git Gui 和 gitk 也可用,带来一些便利,但缺乏资源管理器集成(至少在覆盖方面)。但在多头开发盒时代:为什么不在一台显示器(用于一般管理内容的显示器)上保持 Git Gui 打开并在另一台显示器上工作呢?

我最近也在工作中的团队中介绍了 Git。我们已经习惯了TortoiseSVN,所以我也向他们展示了如何使用Tortoise添加文件,如何提交等等。但在每张幻灯片上,我还注明了他们必须在 Git Bash 中输入什么才能获得相同的结果。这样,一旦他们更有经验,他们就可以拿出介绍幻灯片并查看他们必须使用的命令。

The answer is: no, you can't.

For me, TortoiseGit is a tool that you can use to make the transition from – in your case – CVS to Git easier (like I wrote in my answer to Does TortoiseGit actually make Git a lot easier to use like TortoiseSVN?). But once the transition is made and your colleagues get more familiar to Git, it's time to come up with the real tools.

And the most powerful tool to interact with Git is the command line. Period. The Git Gui and gitk are also usable, bring some convenience but lack explorer integration (at least in terms of overlays). But in times with multi headed development boxes: why don't keep the Git Gui open on one monitor (the one used for general management stuff) and work on the other?

I recently also did an introduction to Git in my team at work. We were used to TortoiseSVN, so I also showed them how to add files using Tortoise, how to commit and so on. But on every slide, I also noted what they have to type in the Git Bash to achieve the same result. That way, once they're a little more experienced, they can take out the introduction slides and peek at the commands they have to use.

豆芽 2024-11-15 01:43:17

在有限的范围内,您可以在 TortoiseGit 中执行这些操作。例如,有一个重置对话框。它们的功能并不突出(我认为),因为使用 TortoiseGit 意味着您对 git 索引的需求减少了——有方便且功能强大的 GUI 方法来选择和审查您打算提交的内容,因此索引变得不太必要。

话虽这么说,TortoiseGit 为初学者和高级 git 用户带来了许多有用的东西,尽管它只是命令行的补充,而不是替代。

作为额外的过渡,您可能对我使用的批处理文件感兴趣,该文件允许从命令行方便地调用那些 TortoiseGit GUI 窗口,从而稍微模糊了界限:

To a limited extent, you can perform those actions within TortoiseGit. For instance, there is a reset dialog. They aren't prominently featured (I think) because using TortoiseGit means you have less need for the git index -- there are convenient and highly functional GUI methods for choosing and reviewing the things you intend to commit, so the index becomes less necessary.

That being said, TortoiseGit brings many useful things to the table for both the beginner and the advanced git user, though it is only a complement, not a replacement, to commandline.

As an additional transition, you might be interested in a batch file I use that blurs the line a little by allowing convenient invocation of those TortoiseGit GUI windows from the commandline: https://github.com/ses4j/tgit

等风也等你 2024-11-15 01:43:17

事实比迄今为止的答案还要糟糕。我尝试了一个实验:git add 对索引进行一些更改,恢复工作树以匹配当前的 HEAD,然后运行 ​​TortoiseGit 提交。

它将更改的文件列为有资格包含在提交中的文件之一,因此它知道某些内容已更改,这给人的印象是至少它知道如何完成已由另一个工具暂存的提交。但是当我选择它时,提交实际上使用了工作树副本并销毁了索引中未提交的数据,并且提交最终成为对该文件的无操作。

这是一个危险的工具,我想我会避免它。

The truth is even worse than the answers so far have let on. I tried an experiment: git add some changes to the index, restore the working tree to match the current HEAD, and run a TortoiseGit commit.

It listed the changed file as one of the files eligible to be included in the commit, so it was aware something was changed, which gives the impression that at least it knows how to finish a commit that's already been staged by another tool. But when I chose it the commit actually used the working tree copy and destroyed the uncommitted data in the index and the commit ended up being a no-op on that file.

A dangerous tool, I think I'll be avoiding it.

无声情话 2024-11-15 01:43:17

最近,当对相同文件进行更改时,需要使用 git add 来应用存储,并发现我可以通过一个技巧来使用它:在存储库中(创建)一个新文件(.txt)例如),打开提交窗口,该窗口将显示更改的文件以及新文件。选择所有已更改的文件和新文件。右键单击新文件,您将在其中看到Add命令。它将把 git add 应用于所有选定的文件。之后,您可以恢复新文件。
所有这些都允许我对修改后的文件应用存储。

Recently hit the need of using git add to apply stash when there were changes to the same files and found that I can use it with a trick: have (create) a new file in the repo (.txt for example), open commit window that will show changed files along with the new one. Select all changed files and the new file. Right click on the new file and you will have Add command there. It will apply git add to all selected files. After that you can just Revert the new file.
All of that allowed me to apply stash over modified files.

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