Skip to content

Instantly share code, notes, and snippets.

@gobinathm
Created March 6, 2017 18:24
Show Gist options
  • Select an option

  • Save gobinathm/96e27a588bb447154604963e09c38ddc to your computer and use it in GitHub Desktop.

Select an option

Save gobinathm/96e27a588bb447154604963e09c38ddc to your computer and use it in GitHub Desktop.
Fix for Remote rejected shallow update not allowed after changing Git remote URL

Some Time there is a shallow update not allowed issue in your cloned GIT repo.

This means that you have to unshallow your repository. To do so you will need to add your old remote again.

git remote add origin <path-to-old-remote> After that we use git fetch to fetch the remaining history from the old remote (as suggested in this answer).

git fetch --unshallow origin And now you should be able to push into your new remote repository.

@Juliet-Simpson

Copy link
Copy Markdown

A zillion thank yous. You just saved my course project, I think I would fail if I submitted a shallow repo.

@Sergioamjr

Copy link
Copy Markdown

This worked for me:

git fetch --unshallow https://github.com/this_is_the_source_url_from_where_you_did_clone_it.git
git remote remove origin
git init
git remote add origin https://github.com/your_new_repository_url_here.git
git push origin master

@panglars

panglars commented Jun 2, 2022

Copy link
Copy Markdown

thanks!

@yurenchen000

Copy link
Copy Markdown

git checkout --orphan maybe work ?

@dushenyan

Copy link
Copy Markdown

Thank you very much๐Ÿ˜

@GeorgeKontsevik

Copy link
Copy Markdown

nothing worked for me from answers above(

@Barathpalanisamy

Copy link
Copy Markdown

This worked for me:

git fetch --unshallow https://github.com/this_is_the_source_url_from_where_you_did_clone_it.git
git remote remove origin
git init
git remote add origin https://github.com/your_new_repository_url_here.git
git push origin master

its worked

@beijishiqidu

Copy link
Copy Markdown

๐Ÿ˜

@CamiloD16

Copy link
Copy Markdown

Another option:

1 - Delete the file .git
2 - Use git init in the terminal
3 - Add again your repository

@microhello

Copy link
Copy Markdown

git fetch --unshallow https://github.com/this_is_the_source_url_from_where_you_did_clone_it.git
git remote remove origin
git init
git remote add origin https://github.com/your_new_repository_url_here.git
git push origin master

It's worked for me, thank you !

@Shankarv19bcr

Copy link
Copy Markdown

This worked for me:

git fetch --unshallow https://github.com/this_is_the_source_url_from_where_you_did_clone_it.git
git remote remove origin
git init
git remote add origin https://github.com/your_new_repository_url_here.git
git push origin master

its worked

@Barathpalanisamy Yeah Its Worked

@mariohernandez

Copy link
Copy Markdown

The answer in this article worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment