I just replicated the scenario (create files in a git-ignored dir) and switch between branches: files stayed put.
On 04/26/2018 09:46 PM, Ryan Schmidt wrote: > > On Apr 26, 2018, at 20:38, Michael wrote: > >> On 2018-04-26, at 5:01 PM, Ryan Schmidt wrote: >> >>> To do this, I was first required to stash or commit my unfinished work. I >>> used git stash, followed by git checkout my-other-branch. After finishing >>> work there, I returned to my original branch with git checkout >>> my-original-branch, and restored my stashed work with git stash pop. But >>> the /dist/ directory is now gone. >>> >>> Where did git put these files? The /dist/ directory is mentioned in >>> .gitignore. Did it delete them? >> >> If you have some directory mentioned in .gitignore, then git will ignore it. >> It will not delete the files on stash. It will not bother them on checkout. >> If your development on the new branch results in their being deleted, then >> they will be gone. When you check out the original branch, git does nothing >> with the directory. And when you pop the stash, also nothing happens. >> >> So the question is, what did you do to the dist directory when working in >> the other branch? > > I was dealing with this PR: > https://github.com/macports/macports-base/pull/81. So I edited a source file, > ran configure, make, make install, and make test. I also used git add and git > commit --amend to add my changes to the previously-made commit, and git push > --force to update the PR. The dist dir should only be removed by make > distclean, and I didn't run that, and I don't think any of the other makefile > targets run that. > > >> The second question is, is the .gitignore file itself versioned? If so, and >> dist is not ignored on the other branch, then when you saved the other >> branch, you saved the dist directory. In this case, it will be saved in the >> other branch and removed when you check out the new/original work branch. > > .gitignore is versioned and contains /dist/, everywhere; this has not changed > lately. dist is not and should not be committed. > >
