1

I have two branches :

  • master
  • feature-x

In the project, I have a temp folder. This folder is in .gitignore

While being in master, I created a file hamburger.txt inside the temp folder. Then I switched branch for feature-x. The file hamburger.txt disappeared.

Then I switch back to master. The hamburger has disappeared definitely.

Why ? How can I get it back ?

I thought the files / folders in .gitignore were completely ignored by git. How switching branch could make the file disappear ?

lepix
  • 4,992
  • 6
  • 40
  • 53
  • Checking out to a branch shouldn't touch files that are ignored by git. Is the .gitignore file within both branches? – Antti Kuosmanen Oct 26 '15 at 11:39
  • Ouch. Branch `feature-x` didn't ignore the `temp` folder... Is that why ? – lepix Oct 26 '15 at 11:41
  • No. Files should not be removed when you are switching to another branch. Could you can reproduce it? – Mariusz Oct 26 '15 at 11:44
  • The file should have been listed as "untracked" when switching to feature-x. Git will only delete files that are under version controll (except you use Git clean commands or something like that). – BlackEye Oct 26 '15 at 12:59

1 Answers1

0

I could get the file back via git-stash : https://git-scm.com/docs/git-stash

It seems that it is a normal behavior as explained is this possible duplicate : Git is deleting an ignored file when i switch branches

Please not that I sometimes used the Github App for Mac OS to commit / switch branch. Not sure if it plays a role, though.

Community
  • 1
  • 1
lepix
  • 4,992
  • 6
  • 40
  • 53