Home > other >  Is it possible to cherry-pick a git commit without changing it?
Is it possible to cherry-pick a git commit without changing it?

Time:12-29

Situation:

  • I have a repository with commits up to 1234
  • Someone forks it and adds a commit abcd and sends a PR
  • I like to rebase it instead of merge the branch as the branches are not diverged
  • I cherry-pick the commit, but the new commit is now wxyz as git adds a Committer field and probably some other metadata

My current workaround is to manually get fetch their repo and then git reset --hard onto commit abcd. Afterward I can push my branch to my repo.

It would be especially nice, if I could update the branch from a GitHub PR without resorting to manually fetching and pushing just to add a single commit from a GitHub PR to my repo.

CodePudding user response:

You can add their repo as an origin, fetch all commits, and use git merge --ff-only abcd.

  • Related