After git returns the version to a free state, how to submit and push it?

I returned to a certain version under IDEA, and later found that the status was detached, which was actually checkoutcaused by using commands.

git checkoutEssentially, the content in HEAD is modified to point to different branches, and the branch pointed by the HEAD file is our current branch. However, sometimes HEAD does not point to any branch. Strictly speaking, HEAD points to a branch without a branch name. Congratulations on the revised version, it is already in a detached state (detached HEAD). At this time, we commitwill not submit it to any branch during the operation.
Insert image description here
At this time, it is impossible to push to the remote master branch.
Solution:

Create a branch so that the current version has a branch

git checkout -b temp

Then delete the original master branch master

git branch -D master

Rename the newly created branch to master

 git branch -m tempn master

Finally, the commit is forced to the remote branch. The records after the original version of the returned branch are gone, and only the new commit is now available.

git push origin master --force

Guess you like

Origin blog.csdn.net/Fire_Sky_Ho/article/details/119680661