# How to pull code from local machine

**URL:** <https://forum.ansible.com/t/how-to-pull-code-from-local-machine/15673>\
**Category:** Ansible Project\
**Created:** [July 15, 2014, 10:14am UTC](https://forum.ansible.com/t/how-to-pull-code-from-local-machine/15673 "2014-07-15T10:14:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![9devmail](https://avatars.discourse-cdn.com/v4/letter/9/779978/32.png) [@9devmail](https://forum.ansible.com/u/9devmail)\
**Post date:** [July 15, 2014, 10:14am UTC](https://forum.ansible.com/t/how-to-pull-code-from-local-machine/15673/1 "2014-07-15T10:14:23Z")

</div>

I do not have remote git repo, only a local one. Is it possible to pull a local repo to a remote machine?

I tried the following:

`

- name: pull the code  
git: repo=file:///home/username/myproject/.git dest=/var/www

`

and got an error:

`  
stderr: fatal: ‘/home/username/myproject/.git’ does not appear to be a git repository  
fatal: Could not read from remote repository.

`

---

<div class="post-metadata">

**Author:** ![Paul\_Totterman](https://avatars.discourse-cdn.com/v4/letter/p/3ec8ea/32.png) [@Paul\_Totterman](https://forum.ansible.com/u/Paul_Totterman)\
**Post date:** [July 15, 2014, 1:27pm UTC](https://forum.ansible.com/t/how-to-pull-code-from-local-machine/15673/2 "2014-07-15T13:27:52Z")

</div>

> `stderr: fatal: '/home/username/myproject/.git' does not appear to be a git repository fatal: Could not read from remote repository.`

Have you tried if the actual git command succeeds?

> git clone file:///home/username/myproject/.git

I suspect that it should be:

> git clone file:///home/username/myproject

Cheers,  
Paul

---

<div class="post-metadata">

**Author:** ![Michael\_Vermaes](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@Michael\_Vermaes](https://forum.ansible.com/u/Michael_Vermaes)\
**Post date:** [July 15, 2014, 3:10pm UTC](https://forum.ansible.com/t/how-to-pull-code-from-local-machine/15673/3 "2014-07-15T15:10:58Z")

</div>

The docs for the module don’t specifically mention local repos, but I can’t see anything that would prevent it and it worked for me. I think you just need to remove the trailing .git in the repo specification. Try:

- name: pull the code  
git: repo=file:///home/username/myproject/ dest=/var/www

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 15, 2014, 3:39pm UTC](https://forum.ansible.com/t/how-to-pull-code-from-local-machine/15673/4 "2014-07-15T15:39:22Z")

</div>

“Is it possible to pull a local repo to a remote machine?”

Not directly.

You could check out locally and use the synchronize module instead.

---

<div class="post-metadata">

**Author:** ![Michael\_Vermaes](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@Michael\_Vermaes](https://forum.ansible.com/u/Michael_Vermaes)\
**Post date:** [July 15, 2014, 3:52pm UTC](https://forum.ansible.com/t/how-to-pull-code-from-local-machine/15673/5 "2014-07-15T15:52:27Z")

</div>

Sorry, disregard my comment - I misread the question. I missed the reference to the remote machine and was assuming all directories mentioned were local, and the play was being executed with ‘-c local’. This does seem to work, but probably isn’t what is being requested.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 15, 2014, 4:32pm UTC](https://forum.ansible.com/t/how-to-pull-code-from-local-machine/15673/6 "2014-07-15T16:32:48Z")

</div>

Yeah don’t use -c local if just some of your machines are local

- hosts: localhost  
connection: local  
tasks:

- …

- hosts: other  
tasks:

- …

You can also set ansible\_connection=local as an inventory variable.

Ansible will assume localhost means local if not explicitly defined in inventory.
