简体   繁体   中英

How to git cherry-pick commits from a deleted remote branch?

          A--B--C--D = Local + RemoteTracking + Origin: Branch1 {I want ?, E, F from below)
         /
        /     /--?--E--F--G = Branch2 (deleted after merge into Master)
       /     /             \
<--H--/--?--/--I--J---------K--L = Local + RemoteTracking + Origin: Master

I live on Branch1 (very old and unmerged with Master) and need a few commits from a remote Branch2 that has since been merged back into Master. I don't know the total commit history of Branch2 but know I probably need about 3 commits from it (?, E, F). However, I cannot figure out how to find and cherry-pick these exact commits since I can no longer clone this deleted repository.

I cannot tell the history of Branch1 via GitLab/gitk and cannot bring it up in gitlab.com/../branches . I can't use merge-base because I cannot clone the deleted repo. I get a "Fatal: Ambiguous argument" when I try git reflog show Branch2 .

  • With GitLab: Use Repository > Graph to trace the branch visually. Or even better, go to the Merge Request from K and > Overview for Parents, or > Commits where you'd learn what commits there were from that branch/merge to then cherry-pick.

  • From command-line or Git-Bash: I could have looked G or K up through the git reflog (or git log from the Master) if I didn't already know it. But then you could simply git checkout that commit and then git log or gitk from that commit and learned its history.

In my particular case, @eftshift0 was correct in that all commits had been squashed and after @Ôrel's comment I realized I could just find K and singularly cherry-pick G . (If there's a better global/all-case answer I'll take it).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM