8784: Fix test for latest firefox.
[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
7 This tutorial describes how to work with a new Arvados git repository. Working with an Arvados git repository is analogous to working with other public git repositories. It will show you how to upload custom scripts to a remote Arvados repository, so you can use it in Arvados pipelines.
8
9 {% include 'tutorial_expectations' %}
10
11 {% include 'tutorial_git_repo_expectations' %}
12
13 {% include 'notebox_begin' %}
14 For more information about using Git, try
15 <notextile>
16 <pre><code>$ <span class="userinput">man gittutorial</span></code></pre>
17 </notextile> or *"search Google for Git tutorials":http://google.com/#q=git+tutorial*.
18 {% include 'notebox_end' %}
19
20 h2. Cloning an Arvados repository
21
22 Before you start using Git, you should do some basic configuration (you only need to do this the first time):
23
24 <notextile>
25 <pre><code>~$ <span class="userinput">git config --global user.name "Your Name"</span>
26 ~$ <span class="userinput">git config --global user.email $USER@example.com</span></code></pre>
27 </notextile>
28
29 On the Arvados Workbench, click on the dropdown menu icon <span class="fa fa-lg fa-user"></span> <span class="caret"></span> in the upper right corner of the top navigation menu to access the user settings 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>
30
31 Next, on the Arvados virtual machine, clone your Git repository:
32
33 <notextile>
34 <pre><code>~$ <span class="userinput">cd $HOME</span> # (or wherever you want to install)
35 ~$ <span class="userinput">git clone https://git.{{ site.arvados_api_host }}/$USER/tutorial.git</span>
36 Cloning into 'tutorial'...</code></pre>
37 </notextile>
38
39 This will create a Git repository in the directory called @tutorial@ in your home directory. Say yes when prompted to continue with connection.
40 Ignore any warning that you are cloning an empty repository.
41
42 *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.
43
44 <notextile>
45 <pre>
46 <code>~$ <span class="userinput">git config 'credential.https://git.{{ site.arvados_api_host }}/.username' none</span></code>
47 <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>
48 </pre>
49 </notextile>
50
51 h2. Creating a git branch in an Arvados repository
52
53 Create a git branch named *tutorial_branch* in the *tutorial* Arvados git repository.
54
55 <notextile>
56 <pre><code>~$ <span class="userinput">cd tutorial</span>
57 ~/tutorial$ <span class="userinput">git checkout -b tutorial_branch</span>
58 </code></pre>
59 </notextile>
60
61 h2. Adding scripts to an Arvados repository
62
63 Arvados crunch scripts need to be added in a *crunch_scripts* subdirectory in the repository. If this subdirectory does not exist, first create it in the local repository and change to that directory:
64
65 <notextile>
66 <pre><code>~/tutorial$ <span class="userinput">mkdir crunch_scripts</span>
67 ~/tutorial$ <span class="userinput">cd crunch_scripts</span></code></pre>
68 </notextile>
69
70 Next, using @nano@ or your favorite Unix text editor, create a new file called @hash.py@ in the @crunch_scripts@ directory.
71
72 notextile. <pre>~/tutorial/crunch_scripts$ <code class="userinput">nano hash.py</code></pre>
73
74 Add the following code to compute the MD5 hash of each file in a collection
75
76 <notextile> {% code 'tutorial_hash_script_py' as python %} </notextile>
77
78 Make the file executable:
79
80 notextile. <pre><code>~/tutorial/crunch_scripts$ <span class="userinput">chmod +x hash.py</span></code></pre>
81
82 Next, add the file to the git repository.  This tells @git@ that the file should be included on the next commit.
83
84 notextile. <pre><code>~/tutorial/crunch_scripts$ <span class="userinput">git add hash.py</span></code></pre>
85
86 Next, commit your changes.  All staged changes are recorded into the local git repository:
87
88 <notextile>
89 <pre><code>~/tutorial/crunch_scripts$ <span class="userinput">git commit -m "my first script"</span>
90 </code></pre>
91 </notextile>
92
93 Finally, upload your changes to the remote repository:
94
95 <notextile>
96 <pre><code>~/tutorial/crunch_scripts$ <span class="userinput">git push origin tutorial_branch</span>
97 </code></pre>
98 </notextile>
99
100 Although this tutorial shows how to add a python script to Arvados, the same steps can be used to add any of your custom bash, R, or python scripts to an Arvados repository.