DEV Community

Cover image for Push git cloned repository to your own on GitHub

Push git cloned repository to your own on GitHub

Sung M. Kim on October 01, 2017

** UPDATE: April 21, 2019 ** Both Eugene Karataev & Noah Pederson provided a better way than what's in this post. Check'em out below. ...
Collapse
 
karataev profile image
Eugene Karataev •

It's not necessary to remove old origin and create a new one. You can just change the existing origin url:
git remote set-url origin NEW_URL

Collapse
 
dance2die profile image
Sung M. Kim •

👆
Wow 😲, Eugene. Thanks for the set-url option.

To borrow from SQL, my posts is using "DELETE" then "INSERT"

while your command does an "UPDATE".

Much simpler.

Collapse
 
zeeshan profile image
Mohammed Zeeshan •

So does this preserve editing history?

Collapse
 
dance2die profile image
Sung M. Kim •

That is a better option than what the post showed 👍

I've only learned of it recently when someone forked my repo and renamed it to create a useful library out of it.

GitHub logo edewit / react-use-sessionstorage

⚓ React hook for using local storage

react-use-sessionstorage

Fork of github.com/dance2die/react-use-loc... but then uses session storage instead of local storage.

How to use it

import React from 'react';
import ReactDOM from 'react-dom';
import useLocalStorage from 'react-use-sessionstorage';
import './styles.css';

function App() {
  const [item, setItem] = useSessionStorage('name', 'Initial Value');

  return (
    <div className="App">
      <h1>Set Name to store in Local Storage</h1>
      <div>
        <label>
          Name:{' '}
          <input
            type="text"
            placeholder="Enter your name"
            value={item}
            onChange={e => setItem(e.target.value)}
          />
        </label>
      </div>
    </div>
  );
}

const rootElement = document.getElementById('root');
ReactDOM.render(<App
…
Enter fullscreen mode Exit fullscreen mode
Collapse
 
donblanco profile image
Glenn Dixon •

I tried the 'set-url' and it did not work. Following the remove instructions did, thanks!

Collapse
 
dance2die profile image
Sung M. Kim •

Weird that set-url didn't work.

Any errors thrown?

GitHub documentation still shows it as a valid option.

help.github.com/en/github/using-gi...

Collapse
 
saiafonua profile image
Saia Fonua •

Thank you good sir!

Collapse
 
dance2die profile image
Sung M. Kim •

You're welcome~

Collapse
 
fahadzakir7 profile image
Fahad Zakir •

Awesome, got all three ways of doing this, best part was posting the suggested ways on top as well.

Thanks from a newb.

Collapse
 
ofu997 profile image
Oliver Fu •

Thanks. I was wondering about boilerplates and whether I needed to publish my own npm package. I hope this works if the original repository is also your own.

Collapse
 
laibazahoor1 profile image
Laiba Zahoor •

You literally make my day, I was unable to solve this issue for 2 days but now it works,,,,

Collapse
 
yeasin2002 profile image
Md Kawsar Islam Yeasin •

Is this necessary to remove origin and I have to create repo again. Is there any way so can push my change into my repo that i clone?