Git only wants to partially update the files in the remote warehouse

question

now suppose that a configuration file, config.json, is added to the remote repository. After I git clone the remote repository, I make changes to config.json. But I don"t want to commit my changes to the remote repository, and I don"t want to update this file every time I update from the remote warehouse (other files are updated as well). Is there any good solution?

the solution I can think of

I only think of git stash caching local changes before each git pull , and then git pull , and then git stash pop overwrites remote repository updates with locally cached changes

.

but it"s a bit troublesome to do this every time. Is there any way to let git know that I don"t want to update the config.json file in the remote warehouse, I just want to update other files?

Git
Feb.16,2022

git checkout config.json is fine


the solution is to keep config.json out of version control

the details are as follows:
create a new .gitignore file in the project root directory, and
write config.json in the .gitignore file


1. If you have pushed a file that has been (push), you want to ignore it when submitting it later, even if it has been modified locally and the corresponding file in the git remote library is not deleted.
execute the command: git update-index-- assume-unchanged config.js ;
2. If you have pushed the (push) file, you want to delete it from the git remote library and ignore it in future submissions, but you still want to keep the file locally.
execute the command: git rm-- cached config.js ;


git checkout-- the file name is fine.


Hello, landlord, how did you finally solve the problem?

Menu