Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Pull a Single Commit In Git?

Someone fixed an error in a program on Github, but it hasn't been added to the master branch. I want to just pull this one commit, but everything I've tried gives an error saying bad object.

like image 344
Kookerus Avatar asked Apr 13 '15 13:04

Kookerus


1 Answers

It would be easier to:

  • git fetch (the brings everything locally)
  • git cherry-pick <SHA1 of the right commit>

Once the fetch is done, you can cherry-pick the commit which fixes the error (it should be part of git log origin/xxx, with xxx being the branch where the bug fix was committed on the GitHub side)

Once the bug fix locally cherry-picked in the local master branch, a simple git push will publish that new commit on the GitHub master branch.


If the commit is from another fork:

git remote add otherfork /url/to/other/fork
git fetch otherfork
git cherry-pick <commit>
like image 54
VonC Avatar answered Nov 14 '22 22:11

VonC