Skip to content

How to push only the required files and exclude unnecessary files (e.g., package.json and package-lock.json)? #466

Answered by Nikhil1017
PiyushKalyanpy asked this question in Q&A
Discussion options

You must be logged in to vote
  1. The simplest way to is to use the Discard button in Github extension for VS code

This will undo all the changes for a specific file so that it will not be included in the PR

  1. Another way is to use the CLI command
 git restore filename

For Example

 git restore package.json 

This will undo all changes for package.json.

  1. If for some reason, you want to keep the package.json file after pushing, you can follow this procedure. First before pushing use the command
 git stash push package.json

This will undo the changes, now push the PR.
Now after pushing the PR use the command

git stash pop 

This will bring back the changes in your local repository.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by PiyushKalyanpy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants