how to merge to a local branch after checking out to a previous commit
I am working on a local branch
VISS. Then I decided to check out a previous commit:
git checkout 98ea3c8042c39e
Move commits from master onto a branch using git Managing files through Git that will never be committed Is there an upper limit to the number of commits a git repository can handle? Which SCM/VCS cope well with moving text between files? git fatal:No tags can describe <sha1 number> Git commit list
I made some important changes to the code. and then I committed again.
Now I need to go back to my branch
VISS keeping these changes.
What should I do if I want to:
Go back to my
VISSbranch discarding what was done before checking out to a previous commit (
Go back to my
VISSbranch merging the new changes with what I had done on the top of the
One Solution collect form web for “how to merge to a local branch after checking out to a previous commit”
Go back to your branch and discard everything :
git checkout VISS
Your new commit atop
98ea3cwill be left floating in the middle of nowhere, and will eventually be garbage collected by git.
Conversely, if you are willing to make
98ea3cthe top of
VISSand discard what
VISSis currently pointing to, do the following:
git checkout VISS git reset --hard 98ea3c
Go back to
VISSand merge your new changes on the top of it:
# On the new commit you just made: git rebase VISS # Now take note of what the commit ID is. Assume I got "abc123"; then: git checkout VISS git merge abc123
You’ll now have
VISSwith the change as the latest commit, and no merge commit.