Home > Blockchain >  best way to remove a committed fie from remote after push
best way to remove a committed fie from remote after push

Time:12-15

So long story short. I made a lot of changes to a project ( more than 85 files) and commit and push it to remote(bitbucket), and did 2 more commits after that, now my colleague ask me to not include the yarn.lock and package-lock.json files.
what i did was just normal:

git add .
git commit -m " message"
git push origin myBranch

to push to the remote, and it's only me working on this branch. now my question is, How can I exclude them?
I have found this answer: Git: Remove committed file after push but it makes me more confused

CodePudding user response:

When you added new files you did git add and then committed them. You can do the equivalent thing to remove them. So run git rm and the git commit -m "message". Then when you push to git, the specified files will be removed.

In order that these files are then not included in git add in the future you can add them to a .gitignore file. All files in .gitignore are not added to git.

  • Related