Issue
I want to remove entire "${project.build.directory}" folder from the git tracked changes before i commit. There are dozens if not like a hundred git files in that generated build folder. How can i remove it from the tracked changes? When i try to do
git restore --staged ${project.build.directory}
I get a "zsh: bad substitution" and am unable to restore the maven folder git state. I want to restore the state before i accidentally added the build folder to my tracked folder and also add the project build directory into my .gitignore to prevent it from happening again
Solution
Standard approach is to add your build folder to .gitignore
file.
zsh
complains that ${project.build.directory}
is not an existing variable.
Removing of a directory from tracked changes is made by git rm -r --cached <DIRECTORY>
.
I am not sure whether you aren't mistaking tracked and staged. Tracked means already commited and staged means added but not yet committed. For the staged stuff, you can unstage it using git reset <PATH>
.
Answered By - Roman Pavelka