On commit I am rebuilding my application for a node project and the built files are placed in the dist
directory. To avoid problems with files in the dist
directory already being staged, I do the following:
- Unstage the dist directory
- Reverse any changes in the dist directory
- Stash any unstaged or untracked files
- Build the application
- Stage the
dist
directory - Unstash the unstaged and untracked files
These are the commands I use:
git reset HEAD -- dist && \
git checkout -- dist && \
git stash push -k -u -m "build" && \
npm run build && \
git add . && \
git stash pop
This worked fine until today. I am getting some odd behavior with a deleted file that is undeleted and untracked after the above commands are run.
Before running the above commands the git status
output looks like this:
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: scripts/substenv.js
After running the commands the git status
output looks like this:
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: scripts/substenv.js
Untracked files:
(use "git add <file>..." to include in what will be committed)
scripts/substenv.js
The untracked file appears after the git stash push -k -u -m "build"
command.
Can anyone please explain why/what is happening?