Home > Net >  Git update project from remote repo but keep modified file(s)
Git update project from remote repo but keep modified file(s)

Time:09-03

Im working on a project with 10 more developers. I clone remote repository. Now in order to Docker work, i have to make changes to docker-compose.yml file. But when i want to update my local project (git pull) in case project got changed by someone else, it's saying i have to commit changes first. But i don't want to commit the docker-compose.yml file. I want to update the project, but keep changed docker-compose.yml. Would you please help me how to do that?

CodePudding user response:

You can stash your local changes, pull the updates and then pop the stashed changes:

git stash save
git pull origin
git stash pop

Having said that, if it's common for developers to make changes to the docker-compose.yml file, you should consider adding it to the .gitignore so you don't have to go through this mess each time you pull updates.
One common practice is to ignore docker-compose.yml like that, but have a committed docker-compose.yml.example file that each developer can copy and modify as needed.

  • Related