How to Push Specific Commit With Git

  • Sometimes we made lots of commits locally and want to push specific commit to the remote branch.
  • I’ll show you how to push specific commit on remote branch.

  • First we need to find out the hash of commit which we want to push on remote.
[mitesh@Matrix ~]$ git log --pretty=oneline
de7e2a469a28d4d74fd4597369cebabd0832636a Test commit for new post
f61b48cb8b1877721e2596a6aa65648a68bb605e new post

Syntax:

git push <remote name> <commit hash>:<remote branch name>
  • Now I want to push only f61b48cb8b1877721e2596a6aa65648a68bb605e commit
# Git push only one commit
[mitesh@Matrix ~]$ git push origin f61b48cb8b1877721e2596a6aa65648a68bb605e:master  
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (10/10), 1.36 KiB | 0 bytes/s, done.
Total 10 (delta 5), reused 0 (delta 0)
To git@github.com:MiteshShah/edytk.github.io.git
   b02924a..f61b48c  f61b48cb8b1877721e2596a6aa65648a68bb605e -> master

Note!: This will push all commits up to and including the specified commit!



Newsletter

Get updated when I create new content.
Unsubscribe whenever. Never any spam.

Note

I'm Tama. I turn down every ad, affiliate, and sponsor request I get. I write free resources that help people. If you enjoy my content, please consider supporting what I do.

Support my work