Irfan Ansari
Irfan Ansari

Reputation: 83

How to push only the latest commit(among many) to Github which is already pushed on Heroku(all of them)?

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?

Upvotes: 0

Views: 132

Answers (1)

Inigo
Inigo

Reputation: 15030

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.

Upvotes: 1

Related Questions