当前位置: 首页 > 工具软件 > Java Gems > 使用案例 >

git安装git flow_从Git安装Gems

翁翰
2023-12-01

git安装git flow

Many gems are hosted on git repositories, such as the public repositories on Github. However, to get the latest version, quite often there are no gems built for you to install with ease. Installing from git is quite easy though.

许多gem都托管在git仓库中,例如Github上的公共仓库。 但是,要获得最新版本,通常没有内置的gem可以轻松安装。 从git安装虽然很容易。

First, you have to understand what git is. Git is what the developers of the library use to track the source code and to collaborate. Git is not a release mechanism. It's important to note that the version of the software you get from git may or may not be stable. It's not a release version and could contain bugs that will be fixed before the next official release.

首先,您必须了解git是什么。 Git是库的开发人员用来跟踪源代码和进行协作的工具。 Git不是释放机制。 重要的是要注意,您从git获得的软件版本可能稳定也可能不稳定。 它不是发行版本,可能包含一些错误,这些错误将在下一个正式版本之前得到修复。

The first thing you have to do in order to install gems from git is install git. This page of The Git Book explains how to do this. It's rather straightforward on all platforms and once it's installed, you have everything you need.

为了从git安装gem,您要做的第一件事就是安装git。 《 Git书》的这一页介绍了如何执行此操作。 在所有平台上都非常简单,一旦安装,便拥有了所需的一切。

Installing a gem from a Git repository is going to be a 4 step process.

从Git存储库安装gem将需要4个步骤。

  1. Clone the Git repository.

    克隆Git存储库。
  2. Change to the new directory.

    转到新目录。
  3. Build the gem.

    建立宝石。
  4. Install the gem.

    安装宝石。

克隆Git存储库 ( Clone the Git Repository )

In Git lingo, to "clone" a git repository is to make a copy of it. We're going to be making a copy of the rspec repository from github. This copy will be a full copy, the same the developer will have on their computers. You can even make changes (though you won't be able to commit these changes back into the repository).

在Git术语中,“克隆” git存储库就是对其进行复制。 我们将从github复制rspec存储库。 该副本将是完整副本,与开发人员在其计算机上拥有的副本相同。 您甚至可以进行更改(尽管您将无法将这些更改提交回存储库中)。

The only thing you need to clone a git repository is the clone URL. This is provided on the github page for RSpec. The clone URL for RSpec is git://github.com/dchelimsky/rspec.git. Now simply use the "git clone" command provided with the clone URL.

克隆git存储库唯一需要的就是克隆URL。 这在RSpec的github页面上提供。 RSpec的克隆URL为git://github.com/dchelimsky/rspec.git。 现在,只需使用克隆URL随附的“ git clone”命令。

$ git clone git://github.com/dchelimsky/rspec.git
$ git clone git://github.com/dchelimsky/rspec.git

This will clone the RSpec repository into a directory called rspec. This directory should always be the same as the final part of the clone URL (minus the .git part).

这会将RSpec存储库克隆到名为rspec的目录中。 此目录应始终与克隆URL的末尾部分相同(减去.git部分)。

转到新目录 ( Change to The New Directory )

This step, too, is very straightforward. Simply change to the new directory created by Git.

此步骤也非常简单。 只需更改到Git创建的新目录即可。

$ cd rspec
$ cd rspec

建立宝石 ( Build the Gem )

This step is a bit more tricky. Gems are built using Rake, using the task called "gem."

这一步比较棘手。 使用称为“宝石”的任务,使用Rake构建宝石。

$ rake gem
$耙宝石

It may not be that simple though. When you install a gem using the gem command, silently in the background it does something rather important: dependency checking. When you issue the rake command, it may come back with an error message saying it needs another gem installed first, or that you need to upgrade a gem already installed. Install or upgrade this gem using either the gem command or by installing from git. You may have to do this several times depending on how many dependencies the gem has.

虽然可能不是那么简单。 当您使用gem命令安装gem时,它会在后台静默地执行一些重要的工作:依赖项检查。 发出rake命令时,它可能会返回一条错误消息,提示它首先需要安装另一个gem,或者您需要升级已经安装的gem。 使用gem命令或从git安装或安装此gem。 您可能必须执行几次此操作,具体取决于gem有多少依赖关系。

安装宝石 ( Install the Gem )

When the build process is completed, you will have a new gem in the pkg directory. Simply give the relative path to this .gem file to the gem install command. You'll need administrator privileges to do this on Linux or OSX.

构建过程完成后,您将在pkg目录中拥有一个新的gem。 只需将这个.gem文件的相对路径提供给gem install命令即可。 您需要管理员权限才能在Linux或OSX上执行此操作。

$ gem install pkg/gemname-1.23.gem
$ gem install pkg / gemname-1.23.gem

The gem is now installed and can be used just as any other gem.

该宝石现在已安装,可以像其他任何宝石一样使用。

翻译自: https://www.thoughtco.com/installing-gems-from-git-2907751

git安装git flow

 类似资料: