Canceling checkout in GIT
Using the MSYSGIT history browser, I checked for a specific commit. It was a mistake - I was trying to view the files and thought I should check them to see them.
Since then I have not been able to redirect to my remote repo (in GITHub) anymore. Which I understand somewhat, although not completely. [I admit I don't quite understand how validation works, please be careful on noob.]
How can I cancel this check and return it to the state it was in before?
If I right click on the checkout commit, I get the option to โdelete this branchโ. Will it be possible to delete the files of this commit [bad] or just cancel the check? Am I barking the wrong tree?
source to share
I understand that you accidentally checked out an earlier commit and then made new commits on top of what you would like to keep. First, make sure you have a pointer to the current job:
git checkout -b newbranch
Then check where you were before:
git checkout master
Hopefully this brings you back to your main branch and you can push to GitHub as usual. If you then want to commit to the changes you made, you can merge and (once you are happy) delete the temporary branch:
git merge newbranch
git branch -d newbranch
source to share
A branch is basically a pointer in C ++ terms.
You can try to move the branch to point to a different commit. Use git reset
for this.
git checkout mybranch
git reset mypreviouscommit
This does not remove the commit, but it does mybranch
"point" mypreviouscommit
. So, everything that was in mypreviouscommit
will be there in master
.
source to share