Saving local changes to git repository

Let's say I have a file in the git repository:

#file.py setting1 = default1 setting2 = default2 <some code> 

Now I want to make some local changes that do not return to the repo

 #file.py - local change setting1 = mysetting1 setting2 = mysetting2 <some code> 

Say that in the future the upstream repository will be updated, and I want to change my changes without violating my local settings. IE a git that I could run to update the file so that it is

 #file.py - updated copy setting1 = mysetting1 setting2 = mysetting2 <new code> 

Is there a way to do this, either with branches, or with some other git function where I do not need to put local settings in a separate file?

I saw a few more such questions, but they focus on excluding the whole file.

thanks

+6
source share
2 answers

Take a look at git stash . It is also a “whole file” method, but you may find that it is flexible enough.

Otherwise, using git gui and a lot of reboot ( git rebase --interactive ) or cherry pick ( git cherry-pick ) or just the side branch should help.

+2
source

What you are doing is probably changing the connection strings, etc. This is what is local to your environment. The right way to handle this is through smudge / clean scripts. Take a look at the chapter “Git Attributes” in the Pro Git book (freely available).

+3
source

Source: https://habr.com/ru/post/920839/


All Articles