How to move the ignored files too in a checkout?

46 Views Asked by At

I am working on a branch. There are some ignored files like for example config files and installed composer/bower packages.

If I checkout to an another branch, the ignored files are still there.

I would like to remove them if I check out an other branch, but I would like to get them back, if I checkout the old branch again, to continue the work on it.

How is it possible?


The installed composer packages are not part of the repo, only the composer.json, which defines the dependencies. I do not want to reinstall the packages every time I checkout the branch

The .env is also not part of the repo. It contains the database location, username and password. Which is different on each development environment.

1

There are 1 best solutions below

0
On BEST ANSWER

You can use: git stash --include-untracked. This will create a stash with all the ignored files and then clean them up.

To recover them do: git stash pop. (This will remove the stashed state form the stash list).

If you want to keep the stashed state on the stash list, you can use: git stash apply

For more complete information about the command check git-stash