Home > Enterprise >  Github files are deleting automatically from the repository?
Github files are deleting automatically from the repository?

Time:01-05

I am new to the GitHub

so, I created a repository and started pushing some CPP code files, then after two or three days I again checked my folders(inside the repo) and found that each folder rarely has one file,but I pushed more than 6 files into each folder (amount of folders 5), is there any solution for this problem?

I pushed all the files using git push -f origin main , is this creating the problem, or something else please help? and how do I retrieve those files?

CodePudding user response:

  1. Stop using -f (--force) flag until you really must and know what you're doing:
    1. In most cases it means that something went wrong
    2. If you're using it often and regularly it means that the workflow is flawed
    3. It often leads to trouble
  2. In your repo in github use the commits tab to try to find your missing files: enter image description here
  3. If you cannot find your files in the history in GitHub, you can try with git reflog on you computer. You can find steps in, for example, Git - README.md Disappeared.
  • Related