I created a branch for my change and did a lots of commit over there. But then I wanted to rollback my latest commit. sO i did following 1. I checkout the previous commit with git checkout on my branch. 2. Then I did my changes to local directory and committed the changes.
Now I am not able to push it to the branch head. It is showing as detached head and can't see this commit in GIT UI.
Please note I want to push the changes to the head of my branch and not to the master. Any help?
# create a branch where you're currently pointing at
git branch temp
git checkout your_branch
git merge temp
and the commit you made out of your branch will be brought in, it should be a fast-forward (so without an unnecessary merge commit).
If I understood correctly, you checked out your previous commit without resetting your branch to it, therefore detaching HEAD
. To bring back the branch to your current HEAD
(and drop the commit it was pointing to), just use:
git checkout -B your_branch # Reset your_branch to HEAD and attach to it
If you had already pushed the dropped commit, you will need to --force
the next push.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.