【发布时间】:2021-03-08 10:02:32
【问题描述】:
我一直在本地机器上使用 GIT 进行项目,我对 git 了解不多,但它一直运行良好,我定期添加并提交到 repo,即
git add .
git commit
在使用错误后,我也一直在检查以前的版本:
```git checkout 7640ac36f0a5cfe28bce7f8e5e5fc84f71ca6d71```
我刚刚在 github 中创建了一个存储库,我尝试按照我尝试分支项目的说明将我的项目发送到 github(按照说明)
git branch -M main
这给了我一个关于分离的 HEAD 的错误。
然后我在 SO Fix a Git detached head?
git branch my-temp-workgit checkout mastergit merge my-temp-work
我有一个错误提示
error: Your local changes to the following files would be overwritten by merge:
.idea/codeStyles/Project.xml .idea/codeStyles/codeStyleConfig.xml .idea/encodings.xml
现在我处于一个比我希望的更早的版本,我如何撤消此操作以返回到我以前的版本,然后使 HEAD 不分离,以便我可以添加到远程 Git Repo..
输出来自: git log --graph --oneline --all --decorate
* 0ade9cbf (my-temporary-work) This was the last commit before moving to remote repo
* bc8c309f Commit before updating to android x
* 6335ac8f updated the media player tidied things up still a work in progress.
* fd08c4ab save before removing concatenating media source
* d2869c0b Updated libs including exoplayer
* 42d2fc20 GC some memory leaks found and hopefully rectified...
* b06759f4 added leak canary to detect memory leaks
* ef380de0 removed the unnecessary play fun from main and fav activities as it is implemented in parent class...
* 7640ac36 commit after changing the on button pressed interface in audio fragments to inherit from the base audio fragment
* 1377bdec changed exoplayer fragment to inherit from base audio fragment...
* e35ff716 Commit before implementing bottom sheet factory...
* eeedb7b3 good restore point still not really fully happy with play pause in playlist also more button not working yet
* e5f0bc98 playlist fragment works better now good restore point still work to do to simplify it...
* 24b666f2 playlist slightly improved now it is more dynamic getting the current items in the playlist need attention tho....
* 60886c2a still working on playlist going to be a hybrid of the music live adapter and playlist adapter this will utilise diff utils and swipe delete
* e6415800 Fixed a few compilation errors after changing from java to kotlin small changes of the companion objects
* a24c707e Good clean up most fragments inherit from baseAudioFragment where delete and alter metadata is taken care of....
* bb9d93a2 updated a base audio fragment to remove duplicated code.
* d9d765fa deleting the media source doesnt throw an error now
* 7ff42182 Delete looks like it works while its playing too
* 61f99121 the delete fun in the exoplayer fragment throws a null pointer error this is semi sorted but an error is thrown if a new activity is started
* cb51b6c2 Changed Exoplayer Music service to Kotlin
* 0139aeb9 clean up the fav stopped working now is ok
* eb7e4f2f Tidying up the Exoplayer Fragment changed to Kotlin
* 09661181 Delete whilst in playlist now works...
* 2bce752c removed some repetative code from activities for songs and placed it in base activity tested works fine
* 54e04e3b added ISongExoPlayerCallback delete callback this will delete an id from the playlist before deleting the file from the media store
* 4d9f242a commit after changing min api from 23 -> 30 and target 30
* ab326226 Little Tidy up...
* f148babc Getting there the delete works now this will be a model for the edit and add new file
* 679df68e Commit before change metadata change
* b93006fd Lots of changes
* bdfd2a59 was trying to complete the change metadata class but i have had to return to change item dialog
* a307b90d SdCard Fragment changed to only update the intent service when the item has downloaded fully
* 68f84f7c sorted a few tings out sd card and downloads in api 29 play now
* 48ca5fcf the sd card downloads play now using the url the artist etc still needs a coat of looking at...
* d32506bc Audio Books and Podcasts works now...
输出来自: git 分支 -vv
* master 277f6666 Reverting to old project my-temporary-work 0ade9cbf This was the last commit before moving to remote repo
【问题讨论】:
-
请考虑在继续使用 Git 之前阅读一些有关 git 基础知识的内容。
-
我相信当我从 SHA1 签出时会导致分离状态,这是正确的吗?
-
我不确定:你到底是什么时候得到了分离的头,遥控器在这一切中意味着什么?
-
你能发布
git log --graph --oneline --all --decorate和git branch -vv的输出吗?