0

I have a React app saved in a GitHub repository (git@github.com:USERNAME/REPO-OLD.git). I would like to move all my files in REPO-OLD into a new folder called REPO-NEW:

REPO-NEW > REPO-OLD > React app

How do I update it and replace my GitHub remote URL accordingly (i.e. pushing the project from REPO-NEW instead of REPO-OLD)? Thanks in advance!

Joyce
  • 3
  • 2
  • 1
    You want to move it only locally? The GitHub repo remains the same? If yes, then just rename the folder. Git repository artefacts are stored in `.git` folder. Doesn't matter what the name of your folder is. – maazadeeb Apr 16 '19 at 08:42
  • 1
    Possible duplicate of [How to change the URI (URL) for a remote Git repository?](https://stackoverflow.com/questions/2432764/how-to-change-the-uri-url-for-a-remote-git-repository) – evolutionxbox Apr 16 '19 at 08:44
  • @evolutionxbox it's very similar, but when I tried to do `git remote set-url origin repo-new` I get the error message `fatal: No such remote 'origin'` – Joyce Apr 16 '19 at 08:56
  • You probably need to add it then? – evolutionxbox Apr 16 '19 at 08:56
  • @evolutionxbox I added origin but when I try to push, the following message appears - `error: failed to push some refs to https://github.com/USERNAME/REPO-NEW.git. Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes (e.g. 'git pull ...') before pushing again.` But when I try to do a git pull, another error pops up - `refusing to merge unrelated histories` – Joyce Apr 16 '19 at 09:27
  • How did you create your new remote repo? Is it empty? – evolutionxbox Apr 16 '19 at 09:39
  • @evolutionxbox `git remote add origin https://github.com/USERNAME/REPO-NEW.git` – Joyce Apr 16 '19 at 16:04
  • That’s how you added it as “origin”. How did you create the repo REMOTE-NEW? – evolutionxbox Apr 16 '19 at 18:37
  • @evolutionxbox I created a repo for REMOTE-OLD with `hub create`, is it possible to rename/update that repo instead of making a new one for REMOTE-NEW? – Joyce Apr 17 '19 at 00:22
  • https://help.github.com/en/articles/renaming-a-repository? – evolutionxbox Apr 17 '19 at 08:48

0 Answers0