How to move a commit to another branch in git Kenny Grant on September 20, 2019 Here's a little git problem that happened to me today, which used to be quite scary when I was first learning git but is actually easy to remedy as... Read full post Submit Preview Dismiss Collapse Expand nat_souljah nat_souljah nat_souljah Follow Am a young programmer from Ghana, having just switched from the world of System Administration and Networking, I am enjoying this journey so far and can't wait to take my place in it. Email sodjanathan@gmail.com Location Accra, Ghana Education Computer Science, KNUST Work Junior FullStack Dev Joined Sep 25, 2018 • Sep 13 '21 Dropdown menu Copy link Hide What if I have already sent the changes to remote Collapse Expand hnakao hnakao hnakao Follow Joined May 13, 2019 • Aug 1 '22 Dropdown menu Copy link Hide git reset --hard HEAD~X // where X is the total of commit to move back or git reset --hard a1b2c3d4 // simply provide the hash of the commit you want to revert back to.. and git push origin master --force // change "master" to the branch you want to revert. Collapse Expand Haritsinh Gohil Haritsinh Gohil Haritsinh Gohil Follow Full-stack developer at OptimumItApps, Rajkot, in the love of Javascript, and also like python and php. Location Rajkot Work Senior Full-stack Developer at OptimumItApps Joined Sep 12, 2019 • Dec 22 '21 Dropdown menu Copy link Hide I will pray for you. Collapse Expand Dávid Katona Dávid Katona Dávid Katona Follow Location Vienna, Austria Work PHP Developer at Reinisch Technologies Joined Oct 13, 2020 • Apr 28 '21 Dropdown menu Copy link Hide Thank you! Saved my a** :) Collapse Expand Hisham Mubarak Hisham Mubarak Hisham Mubarak Follow Everything Js Location Kerala Work Full Stack Developer Joined Dec 24, 2018 • Feb 9 '21 Dropdown menu Copy link Hide Thank you. Just what I wanted :) Collapse Expand Ekim Kael Ekim Kael Ekim Kael Follow Software Developer (- #React • #Nextjs • #ReactNative • #Adonisjs -) I love when beautiful things are useful. Don't be afraid to DM Location Cameroon, Yaoundé, Center Region Education High School Degree Work Frontend Developer at Djemo Digital Joined May 27, 2018 • Aug 12 '21 Dropdown menu Copy link Hide Guy! you just saved my life! THANK YOU!!!!! Collapse Expand Harry Bawsac Harry Bawsac Harry Bawsac Follow Joined Jun 16, 2022 • Oct 31 '23 Dropdown menu Copy link Hide Thanks so much! Collapse Expand Almaz Salyakhov Almaz Salyakhov Almaz Salyakhov Follow Joined Aug 20, 2025 • Aug 20 '25 Dropdown menu Copy link Hide git cherry-pick -x abcdef1 option -x add a message link to source commit — useful for history. It look (cherry picked from commit abcdef1) Collapse Expand Christopher Gritton Christopher Gritton Christopher Gritton Follow Joined Jul 26, 2024 • Jul 26 '24 Dropdown menu Copy link Hide Thanks for the article! Helped me get my local commit back on track to the correct branch! Collapse Expand Segun Ajala Segun Ajala Segun Ajala Follow Joined Feb 14, 2023 • Feb 14 '23 Dropdown menu Copy link Hide I signed up so i can tell you thank you Code of Conduct • Report abuse
What if I have already sent the changes to remote
git reset --hard HEAD~X // where X is the total of commit to move back
or
git reset --hard a1b2c3d4 // simply provide the hash of the commit you want to revert back to..
and
git push origin master --force // change "master" to the branch you want to revert.
I will pray for you.
Thank you! Saved my a** :)
Thank you. Just what I wanted :)
Guy! you just saved my life!
THANK YOU!!!!!
Thanks so much!
git cherry-pick -x abcdef1
option -x add a message link to source commit — useful for history. It look (cherry picked from commit abcdef1)
Thanks for the article! Helped me get my local commit back on track to the correct branch!
I signed up so i can tell you thank you