Home > Back-end >  Access other person's forked repo
Access other person's forked repo

Time:08-11


The problem: I have already cloned a repository from github, let us call it git_repo. Thus, git_repo exists as a directory on my Desktop.
A co-worker of mine has forked git_repo. Their fork contains code which does not exist locally on my machine. Their code only exists on the fork and not on main.
I am now taking over my co-workers project so I need to access the code they have been working on.
My question is how should I do this.
I cannot have two directories on my Desktop both of name git_repo.
I have tried to do:

$ git remote add theirusername [email protected]:theirusername/reponame.git
$ git fetch theirusername
$ git checkout -b mynamefortheirbranch theirusername/theirbranch

however, this has not worked for me.
Specifically, running git remote add theirusername [email protected]:theirusername/reponame.git returns fatal: not a git repository (or any of the parent directories): .git
Should I ask my co-worker to merge their fork with the main branch? However, their fork contains multiple merge conflicts.
I am unsure on what the proper git hygiene is in this case.
Is it possible to transfer owernership of a forked repo? More explicitly I mean that the forks as listed on github change from: their_username/git_repo to my_username/git_repo.
Any help is greatly appreciated. Thank you for your time :)

CodePudding user response:

@joanis's comment was able to help me. They said to just type git clone <url-to-their-fork> reponame-fork. A more in depth explanation is in the comments above.

CodePudding user response:

You need to run the git remote command inside your local repository, then the rest of the commands should work.

However, this is the first step, you are going to need to learn how to integrate his remote branch, so it would help you to read the relevant chapter in the ProGit book: Git Branching - Remote Branches. For setting up the remote in the first place: Git Basics - Working with Remotes.

  • Related