Can I lose files using git?

I’m doing first steps with git. Just wanted to ask if there is a scenario when I can loose files tracked by git?

Let me explain what I mean. I’ve been following a git tutorial.
First, I’ve added a file to a git repo.

  • Ignore one line in a specific file in Git
  • FileVault in cq5 with GIT repository on Windows platform
  • can't find api token in Github
  • GitHub: how to manually deploy all code to production server
  • How to create a tag on GitHub when a PR is merged?
  • git reset vs git reset HEAD
  • git add README
    git commit -m "readme"

    Then I’ve removed the file.

    git rm README

    Since I’m a complete newbie, I’ve been expecting that this command would just stop tracking the README in my repository. However the README has gone away. And I’ve got scared to have lost it forever.

    Lucky enough there is a “git reset –hard” command that can get my README back. But I could have commited a change so this command would not help. Lucky enough I could do “git reset –hard hash” or “git revert” to get my README back in this situation.

    So, basically my question is if there are situations where I could have removed the file and wouldn’t be able to get it back.

    Thanks in advance.

  • Grit commit seems to be overriding last commit in Git repo?
  • GIT Renaming a branch and keeping all commit history
  • Angular error for Include BrowserAnimationsModule
  • Git - Rolling back to before changes
  • Linking repo subfolders with git
  • Git Revision Diff
  • One Solution collect form web for “Can I lose files using git?”

    git rm README will remove the file both from the tracking index and the working tree.

    If you just want to stop tracking the file, you could use:

    git rm --cached README

    See: removing files from git

    Git Baby is a git and github fan, let's start git clone.