rebase - git change intermediate commit without changing later one -




this happens me (well, maybe frequently):

note: of following happens before push.

my software project needs new feature. code , test until works. had had make room new feature, divide changes 2 commits using git add -i:

a --- r --- f 

commit r introduces refactoring changes, f adds code new feature.

now realise made mistakes in dividing changes, in f belong r already, , vice versa. so, basically, r messed , doesn't pass tests (whereas final state of f perfect).

to fix that, check out r on temporary branch , fix everything. git commit --amend , have

a --- r --- f   \    \-- r' 

so missing moving f new branch. far, solution git rebase --onto r-prime r f (i use branch names, see mean). problem it's not want: git understands want move changes between r , f onto r', giving me commit f' might different f. however, want f' same f, except ancestor. frequently, rebase causes conflicts tricky fix (i.e. error-prone).

is there way tell git want move snapshot of f, not diff rf?

assuming current head @ r', should (substitute hashes instead of f , r')

git reset --hard f git reset --soft r' git commit -c f 

it takes tree f is, , commits child of r', substituting commit message f , invoking editor change it





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -