Saving local overwrites and reapplying them as modified after git pull
We use a configuration management repository for our big project. I have to change some of the general settings for some of my special work cases.
Therefore I have to modify some of the configuration files, but still want to be able to save these changes, when I update the project from remote (
git pull). Ideally my changes should show as modified in
- Git workflow for small web team
- MySQL Version Control - Subversion
- Git workflow: leave or keep an old code?
- git usage with remote 'origin' repository
- Proper workflow using git and github
- Git - template repo pull into new repo
I did not find a question about this special work flow case so far. So whats the best approach?
2 Solutions collect form web for “Saving local overwrites and reapplying them as modified after git pull”
You can use
git stash to store your working folder (uncommitted) changes.
git pull, you can reapply those changes using
git stash pop.
wolfs answer is possibly the easiest and most convenient way. When you want to (remotely) backup your changes or keep different versions, here is another approach:
Create a branch and then commit the modified version there.
Then you apply the changes of that commit as modified to your current head via:
git cherry-pick <commit-hash> git reset --mixed HEAD~1
reset –mixed option: changed files are preserved but not marked for commit. It’s the default option.
When you want to save a different personal modified version, create a new branch and proceed as above.