Kookerus
Kookerus

Reputation: 536

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.

Upvotes: 10

Views: 11940

Answers (1)

VonC
VonC

Reputation: 1323125

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>

Upvotes: 18

Related Questions