Switched Branch After .gitignore and lost .gitinored files

I am new to git, so sorry if this question has already been answered. I’m having trouble finding the answer to this.

I wanted to ignore a set of files that had never been committed before for a commit and used the github app to select them and ignore them. I switched to another branch for a while and when I returned to my branch, my ignored files were gone.

  • Is there a faster way to integrate a feature branch?
  • does Java have API wrappers around subversion and Git?
  • Git: Change timestamp after pushing
  • JSHint on Git Push (Update Hook)
  • Stumped by Git/Xcode and GitHub for Mac
  • git gc: no space left on device, even though 3GB available and tmp_pack only 16MB
  • Are these files deleted?

    I used git checkout to switch back to the branch and then git status –ignored . My missing files are not there.

  • How do I execute a job for specific branch/tag on Gitlab CI 5.4+?
  • git repository on github
  • How to exclude certain directories/files from git grep search
  • Pull request merged, closed, then reverted - now can't pull the branch again
  • Finding most changed files in Git
  • Git - fatal: Unable to create '/path/my_project/.git/index.lock': File exists
  • 2 Solutions collect form web for “Switched Branch After .gitignore and lost .gitinored files”

    You can do this by using git reflog -all to get the SHA code from when the Github App automatically stashed your ignored files before switching to the other branch. See https://stackoverflow.com/a/8865242/2970321.

    For example, I fetched a pull request (/pr/364) using the app (SHA 2ba129d). Before I switched back to gh-pages, it stashed my ignored files (SHA 36edfc6).

    finding the SHA code of a dropped stash

    So to recover, all I needed to do was:

    git checkout 36edfc6

    My files magically reappeared, and I was able to safely stash them manually somewhere else before switching back to gh-pages again.

    git doesn’t delete files it doesn’t care about unless specifically told to do so (by checkout -f in some cases of checking out, or clean). As git knows nothing about them, it can’t resurecct them either. Use git stash before moving around and doing possibly damaging stuff. Consider carefully which files go into .gitignore, add all non-automatically-generated files to version control.

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