git - how do you cherry pick changeset from a remote repository

Use case scenario

Let's say your organization is migrating git from Azure Devops (Repo A) to Github enterprise (Repo B). So you have migrated all commit history until 1st Jan 2026. However, there's a developer makes additional changes to Azure Devops. How do you cherry pick those changeset to Github enterprise (Repo B) 

You can do the following 

cd RepoB

git remcoote add azure-devops https://your-azure-devops/repo.git

git fetch azure-devops 

# then we create a new branch so we can raise a PR to main 

git checkout main -b feat/changeset-new-for-ado-repo

(on a separate window, run the following)

git log --online HEAD..azure-devops/master (get all the changeset from ADO)

You will see commits - these commit can consist of normal commits and MERGE commits. 

Given that you already get all the changeset from ADO, now it is time to use git cherry-pick to get those changeset into your branch. 

Merge commit

If it a merge commit, then we need to do 

git cherry-pick -m 1 <commit>

Very likely you will get git cherry-pick is empty. Given it is a merge, you will get this message.  Then you need to 

git comit --allow-empty

If will fire up a vi or vim editor that allows you to update the merge requests.. 

Normal commit 

For normal commit, you typically would be able to do 

git cherry-pick <commit-id> 

And the changeset would be available. 

I think it is best to go from oldest commit to latest (new) commits.

 






Comments

Popular posts from this blog

gemini cli getting file not defined error

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

vllm : Failed to infer device type