-2

That's how if, for example, I have a task from my teacher and have it upload to my own github account.

Then it makes mistakes every time I write like this:

git init

Error are:

Reinitialized existing Git repository in C:/Users/ImGuud/Documents/NetBeansProjects/HelloWorld/.git/

i have read: Does running git init twice initialize a repository or reinitialize an existing repo?

But what I want it to do is be the upload to my own github and not the former github that I have clone from.

  • 2
    Possible duplicate of [Git push existing repo to a new and different remote repo server?](https://stackoverflow.com/questions/5181845/git-push-existing-repo-to-a-new-and-different-remote-repo-server) – phd Oct 08 '18 at 14:28
  • https://stackoverflow.com/search?q=%5Bgit%5D+push+to+different+remote – phd Oct 08 '18 at 14:28

2 Answers2

0

Add your github as another remote:

git remote add github git@github.com:user/example

Then push there:

git push github master
OhleC
  • 2,821
  • 16
  • 29
0

There are several possible solutions for this:

First you can make a fork of the original GitHub repository to your own account and then clone your fork and work with this (the easiest and perhaps intended way).

The other possibility is to modify your remotes:

On one side you could delete the remote you cloned fron and replace it with your own remote, e.g.:

git remote remove origin
git remote add origin git@github.com:myaccount/repo

The first time you push you must set the upstream with

git push -u origin master

then you can simply work with your own repository.

The next option is the solution @ohlec answered...

In every case you need a repository in your own user account.

A secondary init should never be needed on an existing repository...

Uwe Plonus
  • 9,803
  • 4
  • 41
  • 48