0

In order to debug my Heroku app, I kept on making small changes to my local repository and pushing on Heroku as follows:

git commit -m <message>
git push heroku master

Now the problem is my Github's repository is behind by 10 commits from the local and Heroku repositories. I don't want to push all of those 10 commits to Github since they are just small changes. I read about how to reorder commits to push only the latest commit on Github from here. But by reordering, I think I will face problems later when I push future changes to Heroku.

So I'm looking for answers to the following questions:

1. How can I push only the working commit (i.e. latest one) on Github without any conflicts with Heroku in future?

2. What is the correct way to work with Git when working in such environment?

Irfan Ansari
  • 73
  • 2
  • 9
  • 1
    I don't think Heroku cares about whether the history you're pushing matches what it already has, but if it does you can always `git push heroku master --force`. Force pushing *to GitHub* may not be a good idea, especially if you share the repo with others, but to Heroku it doesn't matter. – jonrsharpe Apr 16 '20 at 08:37

1 Answers1

1

Each Git commit is incremental -- it only contains the changes of that commit. Keeping only the last commit and not the other 9 means that you would lose the changes made in the other 9. Reordering commits just does that: reorders them. You will still have 10 small commits.

I assume you don't want to push the 10 small commits because you want a clean, understandable commit history, and you feel those 10 small commits should appear in the history as one large one. You can make that happen by squashing those commits.

Inigo
  • 12,186
  • 5
  • 41
  • 70