0

My company has a corporate github and every employee has a fork of it.

myCompany/mainRepo

so after forking it, I have harlinton/mainRepo and when I work on my feature, I make a pull request to merge it into myCompany/mainRepo.

A coworker and I are working on a feature and they already have a commit that I want to work off of but it's in their fork, otherCoworker/mainRepo. How can I pull that into my fork so that I have their commit and then continue off of that? I tried grabbing the hash and doing git checkout [hash id] but expectedly, that reference doesn't exist since it's looking in my fork.

  • Why did you all fork? That's antipattern. You should probably be _cloning_, then just work on different branches. Forking is usually only done to publish a project independently. – isherwood Jul 21 '21 at 18:17
  • 1
    Does this answer your question? https://stackoverflow.com/questions/1365541/how-to-move-files-from-one-git-repo-to-another-not-a-clone-preserving-history – isherwood Jul 21 '21 at 18:18
  • 1
    Or this? https://stackoverflow.com/questions/37751928/git-how-to-move-a-branch-between-repositories – isherwood Jul 21 '21 at 18:18
  • 2
    Add your coworker's (github) repo as an additional `remote` to your local repo... then you will be able to see what he posts on his repo. – eftshift0 Jul 21 '21 at 18:27
  • Does this answer your question? [How to move files from one git repo to another (not a clone), preserving history](https://stackoverflow.com/questions/1365541/how-to-move-files-from-one-git-repo-to-another-not-a-clone-preserving-history) – SwissCodeMen Jul 21 '21 at 21:34
  • @isherwood: some companies like this pattern. (I'm not a huge fan, but I also have not worked for a company where all the Git users are clueless newbies :-) ) – torek Jul 21 '21 at 22:23
  • Does this answer your question? [Git pull a branch from a different repository](https://stackoverflow.com/questions/39538520/git-pull-a-branch-from-a-different-repository) – Elias Holzmann Jul 22 '21 at 09:27

0 Answers0