Push git cloned repository to your own on GitHub

git, github


title: Push git cloned repository to your own on GitHub date: "2017-10-01" banner: ./images/featured-image.jpg published_at: "2017-10-01T15:26:40.000Z" tags: "git, github" author: Sung M. Kim

UPDATE: April 21, 2019

Both Eugene Karataev & Noah Pederson provided a better way than what's in this post.

Check'em out on the dev.to post thread.

You git cloned a repository from GitHub without forking it.

The problem is that you made a bunch of changes and want to publish it to a new GitHub repository.

What are the steps required to accomplish it?


Remove original remote and add your own


Suppose that you are taking an advantage of all javascript boilerplates floating around on GitHub since setting up Webpack and environment required manually for simple code is a bit too much.


But when you try to commit the code back to GitHub, you get an error message that you don't have a permission since the cloned repo belongs to another user.

dance2die@CC c:\misc\sources\Repos\javascript
> git clone airamrguez/es6-webpack-boilerplate es6
Cloning into 'es6'...
remote: Counting objects: 30, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 30 (delta 11), reused 30 (delta 11), pack-reused 0
Unpacking objects: 100% (30/30), done.
dance2die@CC c:\misc\sources\Repos\javascript
> cd es6
dance2die@CC c:\misc\sources\Repos\javascript\es6
> git push
remote: Permission to airamrguez/es6-webpack-boilerplate.git denied to dance2die.
fatal: unable to access 'https://github.com/airamrguez/es6-webpack-boilerplate/': The requested URL returned error: 403
view raw forbidden.cmd hosted with ❤ by GitHub

How to commit to your own GitHub repository

First, remove the remote repository associated using git remote rm origin.

dance2die@CC c:\misc\sources\Repos\javascript\es6
> git remote -v
origin airamrguez/es6-webpack-boilerplate (fetch)
origin https://github.com/airamrguez/es6-webpack-boilerplate (push)
dance2die@CC c:\misc\sources\Repos\javascript\es6
> git remote rm origin
dance2die@CC c:\misc\sources\Repos\javascript\es6
> git remote -v
dance2die@CC c:\misc\sources\Repos\javascript\es6

Then create your own repository on GitHub.

[caption id="attachment_2722" align="aligncenter" width="755"]

create a new repository
create a new repository[/caption]

After creating the repository, copy the repo URL.

[caption id="attachment_2723" align="alignleft" width="1002"]

copy the repo
copy the repo[/caption]

Now, add the URL to your repo.

dance2die@CC c:\misc\sources\Repos\javascript\es6
> git remote add origin dance2die/es6
dance2die@CC c:\misc\sources\Repos\javascript\es6
> git remote -v
origin https://github.com/dance2die/es6.git (fetch)
origin https://github.com/dance2die/es6.git (push)
view raw add remote.cmd hosted with ❤ by GitHub

Now you can push/publish it to your own repository!

dance2die@CC c:\misc\sources\Repos\javascript\es6
> git push origin master
Counting objects: 30, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (30/30), 3.72 KiB | 544.00 KiB/s, done.
Total 30 (delta 11), reused 0 (delta 0)
remote: Resolving deltas: 100% (11/11), done.
To dance2die/es6
* [new branch] master -> master
dance2die@CC c:\misc\sources\Repos\javascript\es6
view raw git push.cmd hosted with ❤ by GitHub

Wolla! It's committed to your GitHub repository.

[caption id="attachment_2724" align="alignleft" width="1014"]

repo updated~
repo updated~[/caption]


You can simply download a zip version of the repository, git init, then add the remote yourself if you are uncomfortable with git clone.


Help me improve this~

Git command is very flexible that there might be other ways to do it much easier. Please let me know if there is a way to do it without going through all these troubles :)