21700: Install Bundler system-wide in Rails postinst
[arvados.git] / doc / user / tutorials / git-arvados-guide.html.textile.liquid
1 ---
2 layout: default
3 navsection: userguide
4 title: Working with an Arvados git repository
5 ...
6 {% comment %}
7 Copyright (C) The Arvados Authors. All rights reserved.
8
9 SPDX-License-Identifier: CC-BY-SA-3.0
10 {% endcomment %}
11
12 This tutorial describes how to work with an Arvados-managed git repository. Working with an Arvados git repository is very similar to working with other public git repositories.
13
14 {% include 'tutorial_expectations' %}
15
16 {% include 'tutorial_git_repo_expectations' %}
17
18 h2. Cloning a git repository
19
20 Before you start using Git, you should do some basic configuration (you only need to do this the first time):
21
22 <notextile>
23 <pre><code>~$ <span class="userinput">git config --global user.name "Your Name"</span>
24 ~$ <span class="userinput">git config --global user.email $USER@example.com</span></code></pre>
25 </notextile>
26
27 On the Arvados Workbench, click on the dropdown menu icon <i class="fa fa-lg fa-user"></i> in the upper right corner of the top navigation menu to access the Account Management menu, and click on the menu item *Repositories*. In the *Repositories* page, you should see the @$USER/tutorial@ repository listed in the *name* column.  Next to *name* is the column *URL*. Copy the *URL* value associated with your repository.  This should look like <notextile><code>https://git.{{ site.arvados_api_host }}/$USER/tutorial.git</code></notextile>. Alternatively, you can use <notextile><code>git@git.{{ site.arvados_api_host }}:$USER/tutorial.git</code></notextile>
28
29 Next, on the Arvados virtual machine, clone your Git repository:
30
31 <notextile>
32 <pre><code>~$ <span class="userinput">cd $HOME</span> # (or wherever you want to install)
33 ~$ <span class="userinput">git clone https://git.{{ site.arvados_api_host }}/$USER/tutorial.git</span>
34 Cloning into 'tutorial'...</code></pre>
35 </notextile>
36
37 This will create a Git repository in the directory called @tutorial@ in your home directory. Say yes when prompted to continue with connection.
38 Ignore any warning that you are cloning an empty repository.
39
40 *Note:* If you are prompted for username and password when you try to git clone using this command, you may first need to update your git configuration. Execute the following commands to update your git configuration.
41
42 <notextile>
43 <pre>
44 <code>~$ <span class="userinput">git config 'credential.https://git.{{ site.arvados_api_host }}/.username' none</span></code>
45 <code>~$ <span class="userinput">git config 'credential.https://git.{{ site.arvados_api_host }}/.helper' '!cred(){ cat >/dev/null; if [ "$1" = get ]; then echo password=$ARVADOS_API_TOKEN; fi; };cred'</span></code>
46 </pre>
47 </notextile>
48
49 h2. Creating a git branch in an Arvados repository
50
51 Create a git branch named *tutorial_branch* in the *tutorial* Arvados git repository.
52
53 <notextile>
54 <pre><code>~$ <span class="userinput">cd tutorial</span>
55 ~/tutorial$ <span class="userinput">git checkout -b tutorial_branch</span>
56 </code></pre>
57 </notextile>
58
59 h2. Adding scripts to an Arvados repository
60
61 A git repository is a good place to store the CWL workflows that you run on Arvados.
62
63 First, create a simple CWL CommandLineTool:
64
65 notextile. <pre>~/tutorials$ <code class="userinput">nano hello.cwl</code></pre>
66
67 <notextile> {% code tutorial_hello_cwl as yaml %} </notextile>
68
69 Next, add the file to the git repository.  This tells @git@ that the file should be included on the next commit.
70
71 notextile. <pre><code>~/tutorial$ <span class="userinput">git add hello.cwl</span></code></pre>
72
73 Next, commit your changes.  All staged changes are recorded into the local git repository:
74
75 <notextile>
76 <pre><code>~/tutorial$ <span class="userinput">git commit -m "my first script"</span>
77 </code></pre>
78 </notextile>
79
80 Finally, upload your changes to the remote repository:
81
82 <notextile>
83 <pre><code>~/tutorial/crunch_scripts$ <span class="userinput">git push origin tutorial_branch</span>
84 </code></pre>
85 </notextile>
86
87 The same steps can be used to add any of your custom bash, R, or python scripts to an Arvados repository.