I forgot to make a fork on GitHub before starting my work

Suppose I cloned a Project C repo from Project X from github to my local machine. I create a branch for myself locally, do some work on it and do a local location.

Now I want to make a pull request for company C, but I understand that I had to make a fork on gitub in order to create my own repo of project X and clone it, not relay the company C.

How can I recover from this without cloning my plug locally and starting with manual copying? I would like to use git magic to save myself.

+6
source share
2 answers

If you want to follow the development of the project that you cloned, by agreement, we add the upstream remote control in addition to your origin control. Therefore you need to:

  • Run a project on github
  • Rename the current origin remote (which tracks the upstream project) with the new name upstream : git remote rename origin upstream
  • Add your github forked personal project as a remote origin : git remote add origin <URL of your personal github fork>

The idea is to follow the origin naming conventions for your personal repository and upstream for the project repository ...

+4
source

You just need to add your fork as a remote to an existing clone:

 git remote add <any name> <URL of fork> 

You may also want to git remote rm source repo.

+1
source

Source: https://habr.com/ru/post/983501/


All Articles