28

A few days ago I created a repository on Github, then followed the steps to add my existing solution to it. I have no idea what I did wrong, but after a few random 'git add' commands and whatnot, I now get the message in github for windows:

failed to sync this branch.
You might need to open a shell and debug the state of this repo.

Not gonna happen.

A better idea is that I delete the repository at github and start over with my local repository. I know how to delete the repository on github (I know it is easy because I have already done this once.) I am not sure how to start over locally. Is there a git command that is basically "git uninit" or "git deconstruct repository" ?

Ulrich Dangel
  • 4,515
  • 3
  • 22
  • 30
philologon
  • 2,093
  • 4
  • 19
  • 35
  • 4
    Delete the hidden .git folder and start over. – j08691 Aug 11 '12 at 00:48
  • This looks like a duplicate of http://stackoverflow.com/questions/1514054/how-do-i-delete-a-local-repository-in-git – Aaron Kurtzhals Aug 11 '12 at 00:50
  • @j08691 is right. Besides that, maybe you can also use "git init" for initialization, then "git remote add/rm" to update github repo, then "git add -A" to track everything? – CherryQu Aug 11 '12 at 00:53
  • I've been watching traffic on this question since I started it 47 minutes ago. Thanks to most everyone for your help.:: Yes, it is a duplicate of that other question. Sorry, I tried to find those first. :: CherryQu's answer (in the comments) is the simplest solution: doing another git init resets everything. Again, thanks to all. – philologon Aug 11 '12 at 01:32

6 Answers6

60

Git stores everything about a repo at the repo's root in the hidden .git folder. Simply deleting that folder, rm -rf .git makes it as if there never was a repo there.

Matt Greer
  • 60,826
  • 17
  • 123
  • 123
  • 2
    Only works if Git isn't locking the folder. Arbitrarily deleting files is not the answer. – rainabba Mar 18 '14 at 07:44
  • 2
    @rainabba what would you recommend? – Matt Greer Mar 18 '14 at 19:25
  • 1
    Well, Matt Greer's answer sure works for me. I had to do delete my git repository yet /again/ today. (Is github kinda hard to use for occasional users?) Anyway, I have never had trouble with Git locking the folder, so Matt's answer still my accepted answer. – philologon Mar 29 '14 at 21:37
  • 1
    There's nothing "arbitrary" about deleting files that may fix the problem. Thanks Matt for this answer. – levininja Apr 29 '16 at 19:21
9
  • First Go to your local repo
  • Show Hidden Files.
  • You will see a ".git" named folder in your local repo.
  • Delete That.
  • Now open Github for Windows.
  • If you click on that repo in Local Tab, you should get an Error that repo cant be found.
  • There is it, click on Re-Clone Repository button.
  • The Repo will be downloaded again and saved by default in My Documents/GitHub.
Avi
  • 1,341
  • 1
  • 18
  • 28
2

I got this error on GitHub for Windows when I had lost internet connection. Once I got connection back it sync'd up fine. Apparently the error messages on the windows client just aren't descriptive enough to tell you when you've lost connectivity. It was as simple as that.

Jason Shehane
  • 413
  • 4
  • 6
0

There is another option that does not involve using the command line. It goes without saying that yes, you should know how to use it but if you are just learning it's not that simple.

Download TortoiseGit and right-click on the folder containing the repo. Go to TortoiseGit > Push and enter your login details. Badabing.

I use it in tandem with the Github client. Life is easier/quicker now.

MTT
  • 327
  • 1
  • 5
  • 16
0

I'm pretty sure I found this in another stackoverflow (if I see that one I'll put the link here) but restarting Windows actually fixes this problem for me. If I remember right, this is related to Github for Windows updating.

There may be another way to get the app to update correctly and sync without restarting. Everytime I've had this issue though, restarting Windows fixes it.

thinktt
  • 363
  • 2
  • 13
0

git windows even can't clone the repo for me regardless I can clone it in git shell. I fixed it by following steps:

  1. uninstall git for windows.
  2. restart windows.
  3. install git for windows.

without restarting windows won't solve the problem, I did try.

AlanMo
  • 171
  • 1
  • 4