git ended up completely diverged branch -


after trying merge branches, realized ended unrelated history.

so i'm wondering how possible in git!, didn't used --orphan create branch , it's used local repository(no remotes used), although used hooks dump database working directory git status made hooks run git add db.sql; git commit --amend --no-edit many times.

edit: diff result between first commits of each branch (e51b4a2 , 6cf7d37) lies in db.sql!.

commit's log:

* commit 75c0c57 (head -> database) | date:   3 days ago | |     somechanges | * commit b4e667d | date:   3 days ago | |     initial database | * commit 6cf7d37   date:   3 days ago        initial  * commit 6507785 (master) | date:   3 days ago | |     update module | * commit e51b4a2   date:   3 days ago        initial 

git reflog:

75c0c57 head@{0}: checkout: moving master database 6507785 head@{1}: checkout: moving database master 75c0c57 head@{2}: commit: changes b4e667d head@{3}: commit (amend): initial database 202717a head@{4}: commit (amend): initial database 5db604f head@{5}: commit (amend): initial database 6d2dcbd head@{6}: checkout: moving master database 6507785 head@{7}: commit: update module e51b4a2 head@{8}: checkout: moving database master 6d2dcbd head@{9}: checkout: moving database database 6d2dcbd head@{10}: checkout: moving database database 6d2dcbd head@{11}: checkout: moving 6d2dcbd47ce6f57a5a5a767f97b301db78ba11c2 database 6d2dcbd head@{12}: checkout: moving database head 6d2dcbd head@{13}: commit (amend): initial database 7ea51da head@{14}: commit (amend): initial database 0bce495 head@{15}: commit (amend): initial database 8401193 head@{16}: commit: initial database 6cf7d37 head@{17}: commit (amend): initial e51b4a2 head@{18}: checkout: moving master database e51b4a2 head@{19}: commit (amend): initial 3f30042 head@{20}: commit (amend): initial 8c6ef22 head@{21}: checkout: moving database master c2f1f28 head@{22}: commit (amend): initial database c9a3aa6 head@{23}: commit (amend): initial database 13997d1 head@{24}: commit: initial database 8c6ef22 head@{25}: checkout: moving master database 8c6ef22 head@{26}: commit (amend): initial 181978f head@{27}: commit (initial): initial 

here's exact problem:

3f30042 head@{20}: commit (amend): initial 8c6ef22 head@{21}: checkout: moving database master 

at point, you've created copy of initial commit on master, no longer related initial commit on database.

we can show exact state before , after this, reflog.

up head@{22} (before switching master):

a  181978f "initial" <head@{27} a' 8c6ef22 "initial" <head@{26} <master  \   b  13997d1 "initial database" <head@{24}   b' c9a3aa6 "initial database" <head@{23}   b" c2f1f28 "initial database" <head@{22} <database 

note orphaned duplicates causes amends - they're not problem, exist.

after switching master, , doing final amend, get:

a  181978f "initial" <head@{27} a' 8c6ef22 "initial" <head@{26}  \   b  13997d1 "initial database" <head@{24}   b' c9a3aa6 "initial database" <head@{23}   b" c2f1f28 "initial database" <head@{22} <database a" 3f30042 "initial" <head@{20} <master 

see a" unrelated a' unrelated a. first commit, they'd siblings sharing common ancestor. compare b, b' , b", siblings same parent (a').


so i'm wondering how possible in git!

because explicitly told git that. commit a' shared between master , database. amending commit shared between branches problematic amending 1 shared between local , remote repos - point you're changing shared.

if you're not sure stuff, don't use --amend without specific reason. it's not default, why isn't default.

your simplest fix like:

git rebase --onto 3f30042 8c6ef22 database 

(assuming want a" parent of database).


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -