# Deploying CircleCI changes to Heroku using Git

**URL:** <https://discuss.circleci.com/t/deploying-circleci-changes-to-heroku-using-git/25210>\
**Category:** Deployments\
**Tags:** heroku, circle-yml\
**Created:** [September 18, 2018, 3:14am UTC](https://discuss.circleci.com/t/deploying-circleci-changes-to-heroku-using-git/25210 "2018-09-18T03:14:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![crinitic](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/crinitic/32/19190_2.png) [@crinitic](https://discuss.circleci.com/u/crinitic)\
**Post date:** [September 18, 2018, 3:14am UTC](https://discuss.circleci.com/t/deploying-circleci-changes-to-heroku-using-git/25210/1 "2018-09-18T03:14:28Z")

</div>

I am pretty new to Git and automated deployments, and I am trying to deploy the changes done as part of my CI to Heroku.

High-level idea:

1. Send my code to github
2. Circle picks it up, and does some minification
3. Circle runs some tests
4. Circle deploys to Heroku my files (including the changes I have done to them)

Everything works well, except the files I get on heroku seem to be the files on git, not the modified/minified files.

I guess the problem is coming from here in my yml:

```
deploy:
  docker:
    - image: buildpack-deps:trusty
  steps:
    - checkout
    - run:
        name: Deploy Master to Heroku
        command: |
            git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master

```

However, I am not really sure how to change it.

A) Is it bad practice to send to Heroku directly the modified files? Should I first commit them to github in special release folder and then send that to heroku? how?  
B) Is it just something missing in my yml?

Thank you for helping out a beginner 🙂

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [September 18, 2018, 4:58pm UTC](https://discuss.circleci.com/t/deploying-circleci-changes-to-heroku-using-git/25210/2 "2018-09-18T16:58:01Z")

</div>

You could do a `git commit` on CircleCI in the build repo, and then push that to Heroku. Don’t push to GitHub though - these are generated build artefacts and you don’t want them in your central repo, because they just replicate the source files.

---

<div class="post-metadata">

**Author:** ![crinitic](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/crinitic/32/19190_2.png) [@crinitic](https://discuss.circleci.com/u/crinitic)\
**Post date:** [September 18, 2018, 11:38pm UTC](https://discuss.circleci.com/t/deploying-circleci-changes-to-heroku-using-git/25210/3 "2018-09-18T23:38:27Z")

</div>

I did this:

```
command: git config --global user.email "circle_ci_test@project.com" && git config --global user.name "CircleCI test" && git add -f dist && git commit -m "Added dist files"

```

That seemed to work, but after the first commit, but now I am getting this:

```
git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git master
To https://cred...@git.heroku.com/project.git
 ! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://cred...@git.heroku.com/project.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Exited with code 1

```

I also tried to put a -f to my git push, and now I get:

```
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Exited with code 1

```

But the dist folder is still missing on Heroku

---

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [September 19, 2018, 8:58am UTC](https://discuss.circleci.com/t/deploying-circleci-changes-to-heroku-using-git/25210/4 "2018-09-19T08:58:32Z")

</div>

Ah yes, I guess that’s because CircleCI doesn’t just do a `git clone` in the `checkout`, it does all sorts of hard `reset` malarkey (open up the step in the build viewer to see what it does). I guess that because Heroku has an ordinary clone of your project, the new state of the repo at CircleCI is unmergeable.

You could try `--force` with your `push` - the remote copy on Heroku is just a throw-away copy anyway.

---

<div class="post-metadata">

**Author:** ![crinitic](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/crinitic/32/19190_2.png) [@crinitic](https://discuss.circleci.com/u/crinitic)\
**Post date:** [September 19, 2018, 5:25pm UTC](https://discuss.circleci.com/t/deploying-circleci-changes-to-heroku-using-git/25210/5 "2018-09-19T17:25:54Z")

</div>

Thanks for your help, seems much more complicated than expected. I will create the files on Heroku directly with a postinstall script. Thanks for your help though

---

<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:** [December 18, 2018, 5:25pm UTC](https://discuss.circleci.com/t/deploying-circleci-changes-to-heroku-using-git/25210/6 "2018-12-18T17:25:55Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
