--- layout: default navsection: userguide title: Working with an Arvados git repository ... 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. {% include 'tutorial_expectations' %} {% include 'tutorial_git_repo_expectations' %} {% include 'notebox_begin' %} For more information about using Git, try
$ man gittutorial
or *"search Google for Git tutorials":http://google.com/#q=git+tutorial*. {% include 'notebox_end' %} h2. Cloning an Arvados repository Before you start using Git, you should do some basic configuration (you only need to do this the first time):
~$ git config --global user.name "Your Name"
~$ git config --global user.email $USER@example.com
On the Arvados Workbench, click on the dropdown menu icon 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 https://git.{{ site.arvados_api_host }}/$USER/tutorial.git. Alternatively, you can use git@git.{{ site.arvados_api_host }}:$USER/tutorial.git Next, on the Arvados virtual machine, clone your Git repository:
~$ cd $HOME # (or wherever you want to install)
~$ git clone https://git.{{ site.arvados_api_host }}/$USER/tutorial.git
Cloning into 'tutorial'...
This will create a Git repository in the directory called @tutorial@ in your home directory. Say yes when prompted to continue with connection. Ignore any warning that you are cloning an empty repository. *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.
~$ git config 'credential.https://git.{{ site.arvados_api_host }}/.username' none
~$ 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'
h2. Creating a git branch in an Arvados repository Create a git branch named *tutorial_branch* in the *tutorial* Arvados git repository.
~$ cd tutorial
~$ git checkout -b tutorial_branch
h2. Adding files or scripts to an Arvados repository First, create a file named *tutorial.txt* in the local repository. Although this tutorial shows how to add a text file to Arvados, the same steps can be used to add any of your custom bash, R, or python scripts to an Arvados repository.
~$ echo 'hello world' > tutorial.txt
Next, add the new file to the git index.
~$ git add tutorial.txt
Next, commit all the changes to the local repository, along with a commit message that describes what this script does.
~$ git commit -a -m "Added tutorial.txt"
Finally, push the changes in the local repository to the remote repository.
~$ git push origin tutorial_branch