git rebase for keeping most recent commit -
git rebase for keeping most recent commit -
i have commits a, b, c , d , need maintain recent 1 d. see 1 way using git rebase -i --root
can pick , crush commits.
although don't understand difference between pick , crush much, made wondering since commits incremental commit d includes changes in between, why have go through git rebase
keeping recent commit , not delete rest of commits?
or missing fundamental git? can have commits unrelated between each other? i.e someday utilize commit b , in situation utilize recent commit d?
git commits aren't incremental, each commit contains entire tree. user interface presents commit in terms of differences parent. in sense, don't have go through git rebase
maintain recent commit , discard rest, can utilize git commit-tree
plumbing command create commit. total equivalent of rebase line this:
git reset --hard $(git commit-tree head: -m message)
that dense line following:
head:
refers tree object contained in current head commit.
git commit-tree tree -m message
creates new parentless commit contains specified tree, in our case tree of head
. output sha1 of newly created commit.
git reset --hard commit
resets current branch , working tree specified commit, in case newly created root commit.
creating commits without history discouraged git because such commits create hard git operate on data. commands git annotate
, git merge
rely heavily on history beingness available, , without git much less useful tool.
git git-rebase
Comments
Post a Comment