         absolute_path = full_path(repo, commit.path)
         case File.exists? absolute_path do
             false -> 
-                case File.open(absolute_path, [:write]) do
-                    {:ok, file} -> 
-                        IO.write file, commit.content
-                        File.close file
-                        commit_and_push(repo, commit)
+                case File.mkdir_p(Path.dirname(absolute_path)) do
+                    {:ok, _} ->
+                        case File.open(absolute_path, [:write]) do
+                            {:ok, file} -> 
+                                IO.write file, commit.content
+                                File.close file
+                                commit_and_push(repo, commit)
+                            error -> error
+                        end
                     error -> error
                 end
                 

    end

    defp write_and_push(repo, commit) do
        case File.write full_path(repo, commit.path), commit.content do
            :ok -> commit_and_push(repo, commit)
            error -> {:error, error}    

    end

    defp commit_and_push(repo, commit) do
        Logger.info "commit and push"
        Git.add repo, "."
        Git.commit repo, ["-m", commit.commit_message, "--author", commit.author]
        case Git.pull repo do
