How to cherry-pick a commit from another repository
José Miguel Álvarez Vañó
Posted on October 11, 2022
To cherry-pick a commit from another repository you have to first add the other repository as a remote (a remote is a repository whose branches you are tracking). You have to give the remote a name.
git remote add <name> https://github.com/example.git
Then, you have to fetch the branches of the remote.
git fetch <name>
Now that you are tracking the other repository and have fetched the changes you can list the commits of a specific branch and cherry-pick a commit.
git log otherRepo/<branch>
git cherry-pick <commit>
In case that you don't want to track the remote anymore you can remove it with:
git remote remove <name>
More info about working with remotes here.
Resources
💖 💪 🙅 🚩
José Miguel Álvarez Vañó
Posted on October 11, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.