6

I'm trying to completely delete and re-upload my GitHub repository. I'm using Pycharm's GitHub integration, and for the life of me I can't figure out how to make Pycharm forget I ever had GitHub repo setup and just start from scratch.

I even tried moving the .git files to another location and clear Pycharm's cache but the damned thing still remembers it has a Github repository setup even though it doesn't actually exist on GitHub anymore.

Anyone knows how to make Pycharm forget ?

Curtwagner1984
  • 1,908
  • 4
  • 30
  • 48
  • Possible duplicate of [Is it possible to completely empty a remote Git repository?](http://stackoverflow.com/questions/4922104/is-it-possible-to-completely-empty-a-remote-git-repository) – Liam Aug 02 '16 at 15:09

1 Answers1

11

To unlink the git repo to GitHub,

entering git remote -v will list the remotes configured.

origin  git@github.com:user/repo.git (fetch)
origin  git@github.com:user/repo.git (push)
gitlab  git@gitlab.com:/user/repo.git (fetch)
gitlab  git@gitlab.com:/user/repo.git (push)

the one with github.com (https:// or git@) points to the remote to GitHub. (here origin)

To remove a remote, you can,

git remote remove origin 

or in older versions of git,

git remote rm origin 

To add a new github repo as the remote, you can

git remote add <name> <repo url>
example. git remote add origin https://github.com/myusername/myproject.git

To reset the branch to the initial (or any specific) commit,

in the version control > log, scroll down to the initial (or any specific) commit

pycharm version control

and click Reset Current Branch to Here...

then select hard

hard reset git pycharm

and press reset. (this is an irreversible change)

to push the changes in the local repo to the remote repo (after resetting to local to desired commit), run push with -f which forcefully updates the remote. make sure the remote branch is not protected to push -f.

git push -f <remote> <branch> 
example. git push -f origin master

To delete all .git stuff and startover, you may run

sudo rm -rf .git/

at the repo root (this will delete the .git directory, irreversible change) and then run git init

All Іѕ Vаиітy
  • 24,861
  • 16
  • 87
  • 111
  • Thank you for the detailed reply. I'm trying to reset the git repo to the current local changes. I.E Delete the remote repo (which I already have done from the GitHub website) and reupload all the local files from scratch. It seems the hard reset you suggested will do the exact opposite and erase and local changes so the would match the initial commit. (I'm on windows) I also tried erasing the .git folder in the project root. Pycharm still remembers everything... – Curtwagner1984 Aug 02 '16 at 11:52
  • I have updated the answer, try pushing the repo to remote with `-f` – All Іѕ Vаиітy Aug 02 '16 at 15:08