Answer the question
In order to leave comments, you need to log in
How to remove a file from the committee in GIT if it has already been pushed?
I recently got a job as a developer, before that I did not work in a team and now I wanted to find out.
I made a commit, then pushed to a new branch, but it turned out that I had an extra file in it - package-lock.json. I would like to get rid of it, re-commit and push, how to do it?
Do I need to delete the old commit or delete it in some other way?
Answer the question
In order to leave comments, you need to log in
Google to the rescue:
https://git-scm.com/book/ru/v2/%D0%9E%D1%81%D0%BD%...
If you want to directly change your pushed commit, then:
1 - switch to your branch.
2 - make edits (delete your file)
3 - execute
git commit --amend -m "Новое сообщение, которое затрет старое сообщение предыдущего коммита."
git push --force
If package-lock.json is a new file, then your command is doing something wrong... SagePtr has already explained above why this file should be in the repository.
If this file has changed for you, then YOU are doing something wrong ... Most likely you used the npm update command instead of npm install. The latter installs not new versions of packages, but those specified in package-lock.json. This is necessary so that all team members use the same package versions, otherwise expect surprises.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question