0

So I followed and completed this ECMAScript 6 Tutorial yesterday, with no issues whatsoever. And since I am new to Git and was eager to practice the command lines as I go, I maintained some commits as I went through the tutorial (without pushing, of course, because the origin was not mine).

And then just today, I have realized that I did something wrong. Instead of cloning the project straight from the source, I should have created it inside my own Gitlab account instead, via the

enter image description here

feature. This way, I could have been able to push my changes to an origin, and then optionally continue adding more to the project later on, as part of my ECMAScript coding practice.

I tried the instructions from this answer, but it gave me a fatal: remote origin already exists error (see screenshot below).

enter image description here

The way I understand it, I cannot upload the local copy of the project to my new repo, because it is still connected to its original repo (correct me if I'm wrong).

QUESTION: Is there a way to do this?

Of course, I can always do the manual process: create a new project via Git Repo by URL, then go over the tutorial again... but if there's a faster way, I'd like to learn how. Please help.

Community
  • 1
  • 1
ITWitch
  • 1,729
  • 5
  • 20
  • 38
  • 1
    Go to your local copy of project directory find .git folder. Inside that git folder find config file there you will see the origin, now change the value of origin what you want and then on terminal use git push origin yourbranchname. – Tushar Kotlapure Mar 30 '17 at 03:19
  • @TusharKotlapure Hey that's a very neat approach! I have another local project that can benefit from your solution. Can you add your comment below as an answer, so I can vote on it, too? Thanks a lot. I've learned something new. – ITWitch Mar 30 '17 at 03:41
  • 1
    Thanks @ITWitch you can learn more about git config file from this reference. https://git-scm.com/docs/git-config – Tushar Kotlapure Mar 30 '17 at 04:06

1 Answers1

3

git remote add origin failed because there is already a remote called origin.

You can upload to a new remote without removing origin, just add it with a different name:

git remote add test19-gitlab YOUR_REPO_URL

and push (the remote name is needed here):

git push test19-gitlab
Jokester
  • 5,501
  • 3
  • 31
  • 39
  • 1
    Goodness! It turns out I got confused in what `git remote add origin` actually does. I didn't realize I was thinking of it as a `push` action, "adding the local project to my new repo's origin", when all it does is create a "nickname" for my new repo, which I can then use with `git push`. You just made me realize my foolishness. Everything's working now. Thank you very much. – ITWitch Mar 30 '17 at 03:37