Creare una nuova applicazione da un esempio personalizzato in Cloud Code per Cloud Shell
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Un repository di esempio è un repository Git che contiene esempi personalizzati che puoi utilizzare per sviluppare applicazioni. Dopo aver
configurato il repository di esempi, puoi
iniziare a creare applicazioni con questi esempi.
In alternativa, puoi importare il
repository di esempi personalizzati di Cloud Code
per provare gli esempi personalizzati. Per comprendere meglio come vengono configurati i repository di esempi personalizzati, ti consigliamo di provare a clonare il repository e a modificarne la struttura e i contenuti prima di importarlo. A questo scopo, puoi creare nuovi esempi nel repository o modificare il codice sorgente per creare le tue versioni delle app Ciao mondo o Guestbook.
Per seguire le indicazioni dettagliate per questa attività direttamente nell'editor di Cloud Shell, fai clic su Procedura guidata:
Per creare una nuova applicazione utilizzando un esempio dal tuo repository di esempi:
Copia l'URL Git del repository di esempio che vuoi utilizzare. Se utilizzi un repository Git ospitato in tempo reale sulla tua macchina locale, il suffisso .git viene omesso e l'URL è del tipo /path/to/repo.
Nella barra di stato di Cloud Code, fai clic sul nome del progetto attivo.
Nel menu Scelta rapida visualizzato, seleziona Nuova applicazione.
Quando ti viene chiesto il tipo di esempio da utilizzare, seleziona Applicazione personalizzata.
Fai clic su Importa Sample dal repo.
Quando ti viene richiesto l'URL, inserisci l'URL di Git che hai copiato in precedenza.
L'URL in questo esempio utilizza il formato GitHub HTTPS: https://github.com/username/repo-name.git.
Suggerimento per la risoluzione dei problemi:se hai problemi con l'autenticazione Git, controlla che l'accesso Git di Cloud Shell sia configurato correttamente. Per maggiori dettagli, consulta Utilizzare il controllo della versione con l'editor Cloud Shell.
Per utilizzare la versione più recente dei tuoi esempi in Cloud Code, fai clic su
AggiornaAggiorna modelli.
Controlla la finestra del terminale nell'IDE per verificare che il repository sia stato clonato correttamente.
Viene utilizzato automaticamente il ramo predefinito del repository. Per utilizzare un altro ramo:
Modifica il ramo in uso o l'URL del repository nel file settings.json
in cloudcode.customApplications.
Fai clic su Applicazione personalizzata.
Fai clic su
AggiornaAggiorna.
Se il repository non è stato clonato correttamente,
puoi utilizzare l'opzione Gestisci repository per aggiornare i dettagli del repository di esempio con un URL e/o un ramo Git validi.
Dall'elenco aggiornato dei sample, seleziona il sample personalizzato.
Inserisci il nome e la località del progetto.
Fai clic su Crea nuova applicazione.
Cloud Code crea l'app utilizzando l'esempio scelto e la apre per l'utilizzo.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-05 UTC."],[[["\u003cp\u003eA sample repository in Git contains custom samples for developing applications, and can be set up for use by the developer.\u003c/p\u003e\n"],["\u003cp\u003eYou can explore custom sample repository setup by cloning the provided example repository and modifying its structure or sample source code.\u003c/p\u003e\n"],["\u003cp\u003eTo create a new application, copy the sample repository's Git URL, and in the Cloud Code Quick Pick menu, select to import the sample.\u003c/p\u003e\n"],["\u003cp\u003eWhen importing a sample, using an HTTPS Git URL is recommended; SSH URLs require configured SSH keys.\u003c/p\u003e\n"],["\u003cp\u003eTo use the most up to date version of the samples, click the refresh templates button after successfully cloning the repository, and you can also update the repository details by using the Manage Repositories option.\u003c/p\u003e\n"]]],[],null,["# Create a new application from a custom sample in Cloud Code for Cloud Shell\n\nA sample repository is a Git repository that contains custom samples you can use\nto develop applications. After you've\n[set up your sample repository](/code/docs/shell/set-up-sample-repo), you can\nstart creating applications with these samples.\n\nAlternatively, you can import the\n[Cloud Code custom sample sample repository](https://github.com/GoogleCloudPlatform/cloud-code-custom-samples-example/)\nto try custom samples. To better understand how custom sample repositories\nare set up, it is recommended that you try cloning the repository and modifying\nits structure and content before importing it. You can do this by creating new\nsamples in the repository or modifying the source code to create your own\nversions of the Hello World or Guestbook apps.\n\n*** ** * ** ***\n\nTo follow step-by-step guidance for this task directly in the\nCloud Shell Editor, click **Guide me**:\n\n[Guide me](https://ide.cloud.google.com/?walkthrough_tutorial_id=cloud_code_custom_samples)\n\n*** ** * ** ***\n\nCreating your app from an imported sample\n-----------------------------------------\n\nTo create a new application using a sample from your sample repository:\n\n1. Copy the Git URL of the sample repository that you'd like to use. If you're\n using a Git repository hosted live on your local machine, the `.git` suffix\n is omitted and the URL is of the form `/path/to/repo`.\n\n | **Note:** Using an **HTTPS** Git URL is recommended. To use a SSH URL, you'll need to generate and configure SSH keys. For more information, see the documentation for your Git repository hosting service. For example, [GitHub](https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh), [Bitbucket](https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/), and [GitLab](https://docs.gitlab.com/ee/user/ssh/).\n2. In the Cloud Code status bar, click the active project name.\n\n3. In the Quick Pick menu that appears, select **New Application**.\n\n4. When you're prompted for the type of sample to use, select **Custom\n application**.\n\n5. Click **Import Sample from Repo**.\n\n6. When you're prompted for the URL, enter the Git URL you copied earlier.\n\n The URL in this example uses the HTTPS GitHub format: `https://github.com/username/repo-name.git`.\n\n **Troubleshooting tip:** If you're having trouble with Git authentication,\n check to see that your Cloud Shell Git login is set up properly. See\n [Using version control with Cloud Shell Editor](/shell/docs/version-control)\n for details.\n7. To use the latest version of your samples in Cloud Code, click\n refresh\n **Refresh Templates**.\n\n8. Check the terminal window in your IDE to confirm that your repository has been\n cloned successfully.\n\n The repository's default branch is automatically used. To use another branch:\n 1. Edit the branch in use or the repository URL in your `settings.json` file under `cloudcode.customApplications`.\n 2. Click **Custom Application**.\n 3. Click refresh **Refresh**.\n\n If your repository wasn't cloned successfully,\n you can use the Manage Repositories option to update your sample repository\n details with a valid Git URL and/or branch.\n9. From the updated list of samples, select your custom sample.\n\n10. Enter your project name and location.\n\n11. Click **Create New Application**.\n\n Cloud Code creates your app using your chosen sample and opens\n your app for use."]]