# Noob question: git clone into a specific directory

**URL:** <https://discuss.circleci.com/t/noob-question-git-clone-into-a-specific-directory/5263>\
**Category:** Build Environment\
**Created:** [July 21, 2016, 11:02pm UTC](https://discuss.circleci.com/t/noob-question-git-clone-into-a-specific-directory/5263 "2016-07-21T23:02:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![richt](https://avatars.discourse-cdn.com/v4/letter/r/e68b1a/32.png) [@richt](https://discuss.circleci.com/u/richt)\
**Post date:** [July 21, 2016, 11:02pm UTC](https://discuss.circleci.com/t/noob-question-git-clone-into-a-specific-directory/5263/1 "2016-07-21T23:02:49Z")

</div>

Ok this is a completely noob question, so apologies, our build environment has a specific requirement. The git repo needs to live in a subdirectory of $HOME called `git`. How do we do this? It seems as though the default is to do a `git clone` into $HOME. Is there a way to set this. I didn’t see this possible with a first glance at the circle.yml documentation. It says the default is to use $HOME, but doesn’t say how to change it.

---

<div class="post-metadata">

**Author:** ![FelicianoTech](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/felicianotech/32/21348_2.png) [@FelicianoTech](https://discuss.circleci.com/u/FelicianoTech)\
**Post date:** [July 23, 2016, 6:31pm UTC](https://discuss.circleci.com/t/noob-question-git-clone-into-a-specific-directory/5263/2 "2016-07-23T18:31:56Z")

</div>

Have you tried moving the repository to your desired location with `cd`?

---

<div class="post-metadata">

**Author:** ![richt](https://avatars.discourse-cdn.com/v4/letter/r/e68b1a/32.png) [@richt](https://discuss.circleci.com/u/richt)\
**Post date:** [July 23, 2016, 8:07pm UTC](https://discuss.circleci.com/t/noob-question-git-clone-into-a-specific-directory/5263/3 "2016-07-23T20:07:17Z")

</div>

Well cd doesn’t really move anything, there are a couple of tricks here:

1. circleci automatically creates in $HOME (usually /home/ubuntu) a subdirectory named CIRCLECI\_PROJECT\_REPONAME (so if your repo is foo, then it puts it in /home/ubuntu/foo).
2. our build system requires that the repo live in $HOME/git/$CIRCLE\_PROJECT\_REPONAME so you need to move it in the checkout: post: phase which defaults to a current working directory of $HOME/$CIRCLECI\_PROJECT\_REPONAME with `mkdir ../git && mv ../$CIRCLE_PROJECT_REPONAME ../git && mkdir ../$CIRCLE_PROJECT_REPONAME` which moves git repo somewhere else. You need the last mkdir because circleci needs that directory to exist as this is where it wants to start
3. Now when you want to run commands, you need to make sure to set the `pwd:` tag properly and it should be done relative to $HOME/$CIRCLE\_PROJECT\_REPONAME because all those tags are relative to that spot, so it looks like `pwd: ../git/$CIRCLE_PROJECT_REPONAME`
4. I’m not clear how circleci handles spaces and special characters in their shell, so I normally double quote every path name in the circle.yml file just to be safe.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:38am UTC](https://discuss.circleci.com/t/noob-question-git-clone-into-a-specific-directory/5263/4 "2018-06-18T11:38:31Z")

</div>

Closed on June 18, 2018, 11:38am UTC


