Clendon DuRapau
Posted on February 28, 2022
Git workflow can get out of sync between team members, causing some very frustrating merge conflicts. In the excitement of getting a new project rolling and setting up the repository, it’s easy to start making commits without realizing that you’ve forgotten to add that pesky package-lock.json
to .gitignore
or even the target path where all your transpiled files end up.
This can cause things to get ugly fast when working with a team.
Here’s the fastest and easiest solution I have found.
- edit your
.gitignore
file and add the files you do not want tracked. -
run the following in the root directory of your project
git ls-files -c --ignored --exclude-standard -z | xargs -0 git rm --cached
-
Make a new commit
git commit -m "Stopped tracking and deleted files in .gitignore"
Caution:
- The ignored files will not automatically be deleted from your local repository after taking these steps. You will have to do that manually if you want to get rid of them.
-
If you
push
your changes to a remote repository, when other team memberspull
the changes to their local repositories, git will delete the ignored files from their machines. This means that those team members will have to rebuild those transpiled files with the compiler used in the project or thepackage-lock.json
with either
npm install
or
npm ci
Posted on February 28, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.