0

I have the following situation (repo had no activity in the last year):

 repo _
       |
       |_ Fork_1
       |_ Fork_2 ... commit_4 ... commit_5 ... commit_6
       |    
       |_ Fork_my ... commit_12 ... commit_13...

I'd like to get commit_4 and commit_6 from Fork_2 into my fork (Fork_my). What I've done previously, but I feel is not the right approach:

  1. Create a branch from Fork_my:main (my repo:branch name) e.g.: new_merge
  2. Create a pull request new_merge <- Fork_2
  3. Resolve conflicts in Github desktop
  4. Create a new branch with resolved conflicts e.g.: new_merge_final
  5. Pull request Fork_my:main <- new_merge_final (or swap new_merge_final for main and rename)

I'm looking into cherry-pick-ing but still unsure of the workflow.

1 Answers1

0

I think I figured it out:

- create new branch from Fork_my:main - e.g. new_branch
- terminal switch to branch


- git remote -v 

# f_2 is new remote alias
- git remote add f_2 https://github.com/Fork_2_user/Fork_2.git

- git remote -v 
- git fetch f_2  / git fetch --all

# make sure you're back on the branch you want to cherry-pick to

- git status
# shaXXXX are found on the commits (e.g. commit_4, commit_6 as per above scenario)
- git cherry-pick shaXXXX
- git cherry-pick shaXXXX2
...
- git cherry-pick shaXXXXN


# on conflict in terminal - open VS code and resolve by replacing the entire section from <<<<<<< to >>>>>>> (including the <<<<<<< and >>>>>>>) with the correct END-result. Then save the file and return to the command prompt.

# after the above:
 
- git add .

# --no-edit keeps the same commit message, otherwise VIM is opened

- git cherry-pick --continue --no-edit

# START next few lines of code only necessary if changes were made on origin during the cherry-pick process
- git fetch origin

- git branch --set-upstream-to=origin/new_branch

- git pull

# END above few lines of code only necessary if changes were made on origin during the cherry-pick process

- git push -u origin new_branch