Git – Pushing specific commit

with Git you can commit locally and push the commit to a central Git server once everything ready is or if you are back online. But what if you made a lot of commits and you just want to share some commits, but not all.

Let’s say you have made following commits:

  1. 74b6625 commit 1
  2. a8a9b00 commit 2
  3. 1e6cf4b commit 3

and you want to push the change set 74b6625. Following trick helps:

First you need to reorder your commit. The commit(s) you want to push have to be push down.

will open editor and showing following lines

just reorder the line so commit 74b6625 (commit 1) is after 1e6cf4b (commit 3).

after saving the changes, git reorder the commits according the changes you just made.

To push, just run following command:

if you use the SHA-1 of commit 3, then commit 1 and commit 3 will be pushed.

Happy pushing :)

Leave a Reply

Your email address will not be published. Required fields are marked *