简体   繁体   中英

.git folder disappeared, how can I push my changes?

I cloned a repository locally and after I made some changes and wanted to push them I got the message that my folder was not a git repo, and indeed there was no .git folder. I don't know where it went.

So now I have these files that I need to push, how can I create a git repository from that folder that will recognize the changed files so I can push them?

Clone the repository again to another folder. Then, copy the .git folder to your broken project folder.

This doesn't seem, strictly speaking, to be a programming question. More of a technical support issue. You also did not tell us what you've tried so far, so I'm stuck with the standard tech support suggestions:

  1. Have you checked to see if your .git folder is in the recycle bin? If so, just restore it.
  2. Try cloning to a different directory, and copy your changes into that directory (or move the .git folder into your original directory - either way works).
  3. Have you tried any of the multiple | duplicate | questions already answered here on Stack Exchange?
  4. Did you try a Google search ?

usually when you clone a repository you are required to provide the source location and target directory. the target directory is something you create just by providing a name for the folder to be called. My advice would be to try to clone the repository and create a different directory. you will be able to push changes from this directory. When you push from this directory, at first it will probably think that everything has been changed but realistically it is because the directory is brand new with nothing inside it.The source location is given from the github website or whatever git website you may be using

But if you want to create a new git repository then you just need to provide a directory name and the repository will be created for you.

This was achieved using git gui, but other user interfaces might work the same way

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM