[translated] 20160802 3 graphical tools for Git.md

This commit is contained in:
Frank Zhang 2016-08-14 14:40:40 +08:00
parent 18a5651b30
commit 5927329554
2 changed files with 117 additions and 118 deletions

View File

@ -1,118 +0,0 @@
zpl1025
3 graphical tools for Git
=============================
![](https://opensource.com/sites/default/files/styles/image-full-size/public/images/government/BUSINESS_meritladder.png?itok=4CAH2wV0)
In this article, we'll take a look at some convenience add-ons to help you integrate Git comfortably into your everyday workflow.
I learned Git before many of these fancy interfaces existed, and my workflow is frequently text-based anyway, so most of the inbuilt conveniences of Git suit me pretty well. It is always best, in my opinion, to understand how Git works natively. However, it is always nice to have options, so these are some of the ways you can start using Git outside of the terminal.
### Git in KDE Dolphin
I am a KDE user, if not always within the Plasma desktop, then as my application layer in Fluxbox. Dolphin is an excellent file manager with lots of options and plenty of secret little features. Particularly useful are all the plugins people develop for it, one of which is a nearly-complete Git interface. Yes, you can manage your Git repositories natively from the comfort of your own desktop.
But first, you'll need to make sure the add-ons are installed. Some distros come with a filled-to-the-brim KDE, while others give you just the basics, so if you don't see the Git options in the next few steps, search your repository for something like dolphin-extras or dolphin-plugins.
To activate Git integration, go to the Settings menu in any Dolphin window and select Configure Dolphin.
In the Configure Dolphin window, click on the Services icon in the left column.
In the Services panel, scroll through the list of available plugins until you find Git.
![](https://opensource.com/sites/default/files/4_dolphinconfig.jpg)
Save your changes and close your Dolphin window. When you re-launch Dolphin, navigate to a Git repository and have a look around. Notice that all icons now have emblems: green boxes for committed files, solid green boxes for modified files, no icon for untracked files, and so on.
Your right-click menu now has contextual Git options when invoked inside a Git repository. You can initiate a checkout, push or pull when clicking inside a Dolphin window, and you can even do a git add or git remove on your files.
![](https://opensource.com/sites/default/files/4_dolphingit.jpg)
You can't clone a repository or change remote paths in Dolphin, but will have to drop to a terminal, which is just an F4 away.
Frankly, this feature of KDE is so kool [sic] that this article could just end here. The integration of Git in your native file manager makes working with Git almost transparent; everything you need to do just happens no matter what stage of the process you are in. Git in the terminal, and Git waiting for you when you switch to the GUI. It is perfection.
But wait, there's more!
### Sparkleshare
From the other side of the desktop pond comes SparkleShare, a project that uses a file synchronization model ("like Dropbox!") that got started by some GNOME developers. It is not integrated into any specific part of GNOME, so you can use it on all platforms.
If you run Linux, install SparkleShare from your software repository. Other operating systems should download from the SparkleShare website. You can safely ignore the instructions on the SparkleShare website, which are for setting up a SparkleShare server, which is not what we will do here. You certainly can set up a SparkleShare server if you want, but SparkleShare is compatible with any Git repository, so you don't need to create your own server.
After it is installed, launch SparkleShare from your applications menu. Step through the setup wizard, which is two steps plus a brief tutorial, and optionally set SparkleShare as a startup item for your desktop.
![](https://opensource.com/sites/default/files/4_sparklesetup.jpg)
An orange SparkleShare directory is now in your system tray. Currently, SparkleShare is oblivious to anything on your computer, so you need to add a hosted project.
To add a directory for SparkleShare to track, click the SparkleShare icon in your system tray and select Add Hosted Project.
![](https://opensource.com/sites/default/files/4_sparklehost.jpg)
SparkleShare can work with self-hosted Git projects, or projects hosted on public Git services like GitHub and Bitbucket. For full access, you'll probably need to use the Client ID that SparkleShare provides to you. This is an SSH key acting as the authentication token for the service you use for hosting, including your own Git server, which should also use SSH public key authentication rather than password login. Copy the Client ID into the authorized_hosts file of your Git user on your server, or into the SSH key panel of your Git host.
After configuring the host you want to use, SparkleShare downloads the Git project, including, at your option, the commit history. Find the files in ~/SparkleShare.
Unlike Dolphin's Git integration, SparkleShare is unnervingly invisible. When you make a change, it quietly syncs the change to your remote project. For many people, that is a huge benefit: all the power of Git with none of the maintenance. To me, it is unsettling, because I like to govern what I commit and which branch I use.
SparkleShare may not be for everyone, but it is a powerful and simple Git solution that shows how different open source projects fit together in perfect harmony to create something unique.
### Git-cola
Yet another model of working with Git repositories is less native and more of a monitoring approach; rather than using an integrated application to interact directly with your Git project, you can use a desktop client to monitor changes in your project and deal with each change in whatever way you choose. An advantage to this approach is focus. You might not care about all 125 files in your project when only three of them are actively being worked on, so it is helpful to bring them to the forefront.
If you thought there were a lot of Git web hosts out there, you haven't seen anything yet. [Git clients for your desktop][1] are a dime-a-dozen. In fact, Git actually ships with an inbuilt graphical Git client. The most cross-platform and most configurable of them all is the open source Git-cola client, written in Python and Qt.
If you're on Linux, Git-cola may be in your software repository. Otherwise, just download it from the site and install it:
```
$ python setup.py install
```
When Git-cola launches, you're given three buttons to open an existing repository, create a new repo, or clone an existing repository.
Whichever you choose, at some point you end up with a Git repository. Git-cola, and indeed most desktop clients that I've used, don't try to be your interface into your repository; they leave that up to your normal operating system tools. In other words, I might start a repository with Git-cola, but then I would open that repository in Thunar or Emacs to start my work. Leaving Git-cola open as a monitor works quite well, because as you create new files, or change existing ones, they appear in Git-cola's Status panel.
The default layout of Git-cola is a little non-linear. I prefer to move from left-to-right, and because Git-cola happens to be very configurable, you're welcome to change your layout. I set mine up so that the left-most panel is Status, showing any changes made to my current branch, then to the right, a Diff panel in case I want to review a change, and the Actions panel for quick-access buttons to common tasks, and finally the right-most panel is a Commit panel where I can write commit messages.
![](https://opensource.com/sites/default/files/4_gitcola.jpg)
Even if you use a different layout, this is the general flow of Git-cola:
Changes appear in the Status panel. Right-click a change entry, or select a file and click the Stage button in the Action panel, to stage a file.
A staged file's icon changes to a green triangle to indicate that it has been both modified and staged. You can unstage a file by right-clicking and selecting Unstage Selected, or by clicking the Unstage button in the Actions panel.
Review your changes in the Diff panel.
When you are ready to commit, enter a commit message and click the Commit button.
There are other buttons in the Actions panel for other common tasks like a git pull or git push. The menus round out the task list, with dedicated actions for branching, reviewing diffs, rebasing, and a lot more.
I tend to think of Git-cola as a kind of floating panel for my file manager (and I only use Git-cola when Dolphin is not available). On one hand, it's less interactive than a fully integrated and Git-aware file manager, but on the other, it offers practically everything that raw Git does, so it's actually more powerful.
There are plenty of graphical Git clients. Some are paid software with no source code available, others are viewers only, others attempt to reinvent Git with special terms that are specific to the client ("sync" instead of "push"..?), and still others are platform-specific. Git-Cola has consistently been the easiest to use on any platform, and the one that stays closest to pure Git so that users learn Git whilst using it, and experts feel comfortable with the interface and terminology.
### Git or graphical?
I don't generally use graphical tools to access Git; mostly I use the ones I've discussed when helping other people find a comfortable interface for themselves. At the end of the day, though, it comes down to what fits with how you work. I like terminal-based Git because it integrates well with Emacs, but on a day where I'm working mostly in Inkscape, I might naturally fall back to using Git in Dolphin because I'm in Dolphin anyway.
It's up to you how you use Git; the most important thing to remember is that Git is meant to make your life easier and those crazy ideas you have for your work safer to try out. Get familiar with the way Git works, and then use Git from whatever angle you find works best for you.
In our next installment, we will learn how to set up and manage a Git server, including user access and management, and running custom scripts.
--------------------------------------------------------------------------------
via: https://opensource.com/life/16/8/graphical-tools-git
作者:[Seth Kenlon][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[1]: https://git-scm.com/downloads/guis

View File

@ -0,0 +1,117 @@
3 个 Git 图形工具
=============================
![](https://opensource.com/sites/default/files/styles/image-full-size/public/images/government/BUSINESS_meritladder.png?itok=4CAH2wV0)
在本文里,我们来了解几个能帮你在日常工作中舒服地用上 Git 的工具。
我是在这许多漂亮界面出来之前学习的 Git而且我的日常工作经常是基于字符界面的所以 Git 本身自带的大部分功能已经足够我用了。在我看来,最好能理解 Git 的工作原理。不过,能有的选也不错,下面这些就是能让你不用终端酒可以开始使用 Git 的一些方式。
### KDE Dolphin 里的 Git
我是一个 KDE 用户,如果不在 Plasma 桌面环境下,就是在 Fluxbox 的应用层。Dolphin 是一个非常优秀的文件管理器,有很多配置项以及大量秘密小功能。大家为它开发的插件都特别好用,其中一个是几乎完整的 Git 界面。是的,你可以直接在自己的桌面上很方便地管理你的 Git 仓库。
但首先,你得先确认已经安装了这个插件。有些发行版带的 KDE 将各种插件都装的满满的,而有些只装了一些最基本的,所以如果你在下面的步骤里没有看到 Git 相关选项,就在你的配置目录里找找类似 dolphin-extras 或者 dolphin-plugins 的字样。
要打开 Git 集成,在任何 Dolphin 窗口里点击 Settings 菜单,并选择 Configure Dolphin。
在弹出的 Configure Dolphin 窗口里,点击左边侧栏里的 Services 图标。
在 Services 面板里,滚动可用的插件列表找到 Git。
![](https://opensource.com/sites/default/files/4_dolphinconfig.jpg)
保存你的改动并关闭 Dolphin 窗口。重新启动 Dolphin浏览一个 Git 仓库试试看。你会发现现在所有文件图标都带有标记:绿色方框表示已经提交的文件,绿色实心方块表示文件有改动,没加入库里的文件没有标记,等等。
之后你在 Git 仓库目录下点击鼠标右键弹出的菜单里就会有 Git 选项了。你在 Dolphin 窗口里点击鼠标就可以检出一个版本,推送或提交改动,还可以对文件进行 git add 或 git remove 操作。
![](https://opensource.com/sites/default/files/4_dolphingit.jpg)
不过 Dolphin 不支持克隆仓库或是改变远端路径,需要到终端窗口操作,按下 F4 就可以很方便地进行切换。
坦白地说KDE 的这个功能太牛了,这篇文章已经可以到此为止。将 Git 集成到原生文件管理器里可以让 Git 操作非常清晰;不管你在工作流程的哪个阶段,一切都能直接地摆在面前。在终端里 Git切换到 GUI 后也是一样 Git。完美。
不过别急,还有好多呢!
### Sparkleshare
SparkleShare 来自桌面环境的另一大阵营,由一些 GNOME 开发人员发起,一个使用文件同步模型 ("例如 Dropbox!") 的项目。不过它并没有直接嵌入到 GNOME 里,所以你可以在任何平台使用。
如果你在用 Linux可以从你的软件仓库直接安装 SparkleShare。如果是其它操作系统可以去 SparkleShare 网站下载。你可以不用看 SparkleShare 网站上的指引,那个是告诉你如何架设 SparkleShare 服务器的,不是我们这里讨论的。当然你想的话也可以架 SparkleShare 服务器,但是 SparkleShare 能兼容 Git 仓库,所以其实没必要再架一个自己的。
在安装完成后,从应用程序菜单里启动 SparkleShare。走一遍设置向导只有两个步骤外加一个简单介绍然后可以选择是否将 SparkleShare 设置为随桌面自动启动。
![](https://opensource.com/sites/default/files/4_sparklesetup.jpg)
之后在你的系统托盘里会出现一个橙色的 SparkleShare 目录。目前SparkleShare 对你电脑上的任何东西都一无所知,所以你需要添加一个项目。
要添加一个目录给 SparkleShare 追踪,可以点击系统托盘里的 SparkleShare 图标然后选择 Add Hosted Project。
![](https://opensource.com/sites/default/files/4_sparklehost.jpg)
SparkleShare 支持本地 Git 项目,也可以是存放在像 GitHub 和 Bitbucket 这样的 Git 服务器上的项目。要获得访问权限,你可能会需要使用 SparkleShare 生成的客户端 ID。这是一个 SSH 密钥,作为你所用到服务的授权标记,包括你自己的 Git 服务器,应该也是用 SSH 公钥认证而不是用户名密码。将客户端 ID 拷贝到你服务器上 Git 用户的 authorized_hosts 文件里,或者是你的 Git 主机的 SSH 密钥面板里。
在配置要你要用的主机后SparkleShare 会下载整个 Git 项目,包括(你可以自己选择)提交历史。可以在 ~/SparkleShare 目录下找到同步完成的文件。
不像 Dolphin 那样的集成方式SparkleShare 是不透明的,让人心里没底。在你做出改动后,它会悄悄地把改动同步到服务器远端项目中。对大部分人来说,这样做有一个很大的好处:可以用到 Git 的全部威力但是不用维护。对我来说,这样有些乱,因为我想自己管理我的提交以及要用的分支。
SparkleShare 可能不适合所有人,但是它是一个强大而且简单的 Git 解决方案,展示了不同的开源项目完美地协调整合到一起后所创造出的独特项目。
### Git-cola
另一种配合 Git 仓库工作的模型,没那么原生,更多的是监视方式;不是使用一个集成的应用程序和你的 Git 项目直接交互,而是你可以使用一个桌面客户端来监视项目改动,并随意处理每一个改动。这种方式的一个优势就是专注。当你实际只用到项目里的三个文件的时候,你可能不会关心所有的 125 个文件,能将这三个文件挑出来就很方便了。
如果你觉得有好多 Git 网站,只是你还不知道。[桌面上的 Git 客户端][1] 上有一大把。实际上Git 默认自带一个图形客户端。它们中平台适用最广,配置最丰富的是开源的 Git-cola 客户端,用 Python 和 Qt 写的。
如果你在用 LinuxGit-cola 应该在你的软件仓库里有。不是的话,可以直接从网站下载安装:
```
$ python setup.py install
```
启动 git-cola 后,会有三个按钮用来打开仓库,创建新仓库,或克隆仓库。
不管选哪个,最终都会停在一个 Git 仓库中。和大多数我用过的客户端一样Git-cola 不会尝试成为你的仓库的接口;它们一般会让操作系统工具来做这个。换句话说,我可以通过 Git-cola 创建一个仓库,但随后我就在 Thunar 或 Emacs 里打开仓库开始工作。打开 Git-cola 来监视仓库很不错,因为当你创建新文件,或者改动文件的时候,它们都会出现在 Git-cola 的状态栏里。
Git-cola 的默认布局不是线性的。我喜欢从左向右排列,因为 Git-cola 又是高度可配置的,你可以随便修改布局。我自己设置成最左边是状态栏,显示当前分支的任何改动,然后右边是改动栏,可以浏览当前改动,然后是动作栏,放一些常用任务的快速按钮,最后,最右边是提交栏,可以写提交信息。
![](https://opensource.com/sites/default/files/4_gitcola.jpg)
不管怎么改布局,下面是 Git-cola 的通用流程:
改动会出现在状态栏里。右键点击一个改动或选中一个文件,然后在动作栏里点击 Stage 按钮来将文件加入待提交暂存区。
待提交文件的图标会变成绿色三角形,表示该文件有改动并且正等待提交。你也可以右键点击并选择 Unstage Selected 将改动移出待提交暂存区,或者点击动作栏里的 Unstage 按钮。
在改动栏里检查你的改动。
当准备好提交后,输入提交信息并点击 Commit 按钮。
在动作栏里还有其它按钮用来处理其它普通任务,比如抽取或推送。菜单里有更多的任务列表,比如专用的操作分支,改动审查,变更基础,等等。
我更愿意将 Git-cola 当作文件管理器的一个浮动面板(在不能用 Dolphin 的时候我只用 Git-cola。虽然它的交互性没有完全集成 Git 的文件管理器那么强,但另一方面,它几乎提供了原始 Git 命令的所有功能,所以它实际上更为强大。
有很多 Git 图形客户端。有些是不提供源代码的付费软件,有些只是用来查看,有些尝试加入新的特定术语(用 "sync" 替代 "push" ...?) 来重造 Git也有一些是适合特定平台。Git-cola 一直是最简单的能在任意平台上使用的客户端,也是最贴近纯粹 Git 命令的,可以让用户在使用过程中学习 Git高手也很满意它的界面和术语。
### Git 命令还是图形界面?
我一般不用图形工具来操作 Git大多数时候我使用上面介绍的工具是帮助其他人找出适合他们的界面。不过在一天结束的时候不同的工作适合不一样的工具。我喜欢基于终端的 Git 命令是因为可以很好地集成到 Emacs 里,但如果某天我几乎都在用 Inkscape 工作时,我一般会很自然地使用 Dolphin 里带的 Git因为我在 Dolphin 环境里。
如何使用 Git 你自己可以选择;但要记住 Git 是一种让生活更轻松的方式,也是让你在工作中更安全地尝试一些疯狂点子的方法。熟悉 Git 的工作模式,然后不管什么方式使用 Git只要能让你觉得最适合就可以。
在下一期文章里,我们将了解如何架设和管理 Git 服务器,包括用户权限和管理,以及运行定制脚本。
--------------------------------------------------------------------------------
via: https://opensource.com/life/16/8/graphical-tools-git
作者:[Seth Kenlon][a]
译者:[zpl1025](https://github.com/zpl1025)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[1]: https://git-scm.com/downloads/guis