- OpenShift Cookbook
- Shekhar Gulati
- 540字
- 2021-08-05 17:37:37
Cloning the application to the local machine
Every OpenShift application has a private Git repository that houses the application source code. OpenShift uses Git not only as a version control system but also to build and deploy the application using Git's action hooks. In this recipe, you will learn how to get the source code of the OpenShift application on your local machine.
Getting ready
You will need Git installed on the operating system before stepping through this recipe. For Debian-based Linux distributions, you can install Git with apt-get install git
as the root. If you are on Fedora or any other Red Hat-based system, you can install Git with yum install git-core
as the root. Mac and Windows users can download the Git package from the official download site at http://git-scm.com/downloads.
This recipe will use the WordPress application created in the Creating a WordPress application using the web console recipe.
How to do it…
Perform the following steps to clone the repository:
- Go to the Applications tab in the web console at https://openshift.redhat.com/app/console/applications and click on the application to view its details, as shown in the following screenshot:
- Copy the Git repository URL mentioned on the application detail web page, as shown in the following screenshot:
- Open a command-line terminal, go to a convenient location on your machine, and execute the
git clone
command. Replace the repository URL with your application Git URL:$ git clone ssh://52b823b34382ec52670003f6@blog-osbook.rhcloud.com/~/git/blog.git/
How it works…
The first and second steps helped us to locate the application Git repository URL. As discussed in the preceding section, OpenShift uses Git as revision control and a source code management system. Every application has a private Git repository. A Git repository contains all the information needed to retain and manage the revisions and history of a project. OpenShift uses the SSH transport protocol to work with Git repositories. To create a secure communication channel between the local machine and application gear, Git uses the SSH key setup discussed in the Uploading SSH keys using the web console recipe. Nobody will be able to clone your application repository unless you add their public SSH key to your account.
In step 3, you cloned the application Git repository using the clone
command. The git clone
command created a new Git repository based on the original application repository URL. The difference between Git and other version control systems is that Git clones the full copy of the repository, in addition to the working copy, of all the files in the repository. The clone
command will create a new directory on your local filesystem with the same name as the application.
There's more…
You can also specify a different folder name with the git clone
command. Suppose you want to clone the application in the myapp
folder. To do this, execute the following command:
$ git clone ssh://52b823b34382ec52670003f6@blog-osbook.rhcloud.com/~/git/blog.git/ myapp
If you want to allow any of your friends or team members to clone your repository, just add their public key to your account. Follow the Uploading SSH keys using the web console recipe to upload the public SSH key. We will discuss team collaboration in detail in Chapter 2, Managing Domains.
See also
- The Deploying your first change recipe
- 黑客攻防實戰技術完全手冊:掃描、嗅探、入侵與防御
- SOA用戶指南
- 萬物互聯:蜂窩物聯網組網技術詳解
- 局域網組建、管理與維護項目教程(Windows Server 2003)
- 互聯網安全的40個智慧洞見:2015年中國互聯網安全大會文集
- 網絡的琴弦:玩轉IP看監控
- Practical Web Design
- Mastering TypeScript 3
- 物聯網之霧:基于霧計算的智能硬件快速反應與安全控制
- C/C++串口通信:典型應用實例編程實踐
- INSTANT KineticJS Starter
- 光纖通信系統與網絡(修訂版)
- 物聯網工程導論(第3版)
- 深入理解計算機網絡
- Guide to NoSQL with Azure Cosmos DB