0

How do pick only one commit from a branch on a remote repository and merge it to the current branch on my local repository?

I looked around on google, and I found git cherry-pick. But this seems to be for doing this only across branches in the same repository.

ssb
  • 7,422
  • 10
  • 36
  • 61

1 Answers1

5

Fetch the other repo:

git fetch http://github.com/otherguy/forkedproject.git

That downloads all the history from that repo, but without changing HEAD or your staging area.

Then, cherry-pick the commit.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
  • Note that unlike `clone`, `fetch` will pull only one branch head, by default "master". If your commit is on a different branch, you'll need to specify that as the final argument to fetch. – Andy Ross Oct 01 '12 at 22:08
  • @AndyRoss: not exactly. In my Git 1.7.6 at least, `fetch` will retrieve all branches on the remote. – Fred Foo Oct 01 '12 at 22:20