I think you could start with this.
The thing you want is to always ignore the dist directory and make the server (staging or prod) trigger a npm install after it has checked out the latest version.
If you are using yarn or npm v5, commit the yarn.lock or package-lock.json file that it generates.
Then, make it trigger your gulp build with npm's post-install hook.
You can also go with using husky, a npm module which automatically installs itself in the .git directory, letting you define and version git hooks based on commands in the scripts attribute of the package.json.
"scripts": {
"postcheckout": "npm install", // <-- Git hook from Husky
"postinstall": "gulp build" // <-- default npm hook
}
I hope it will resolve your query.