git - How to find the original commit of an amended one? -
actually accident found out interesting. amended change existing local commit. know change hash of original commit - @ least that's thought. seems git creates complete new commit. no problem far.
$ vim foo $ git add foo $ git commit -m "edited foo" $ git log --oneline -n 1 5b122c7 edited foo $ vim foo $ git add foo $ git commit --amend $ git log --oneline -n 1 98f1e64 edited foo $ git show 5b122c7 # wait what?
git show 5b122c7
show me original commit - amended commit effictively new commit.
but why old commit still in repository? okay neat have original commit go back.
but original commit 5b122c7
not appear in git log --all
git revert 5b122c7
not fall 5b122c7
instead previous commit of original one.
i'm curious behavior , want know: there way find original commit 5b122c7
git log
or something? in case don't know hash of original commit: how can find hash?
the old commit still in repository, no longer included in history of branch. so, 5b122c7
cleaned git's garbage collection.
there no direct way discover original commit given hash of new amended commit. amending commit throwing away old 1 , making new one. there no link between them.
within repository amended commit, git reflog
command show hash of old commit. however, not part of else see if clone repository.
Comments
Post a Comment