git及github使用问题记录(持续更新中...)

一、从github上pull了一个仓库到本地,修改了若干内容,本地commit以后,再向github上push的时候,提示everything up-to-date。用 git branch 查看本地分支,发现有两个分支:
    *(no branch)
        master
因而 git checkout master ,杯具来临了,修改的内容不见了,git log查看不到上次commit的记录。翻箱倒柜的找度娘求助,(不是谷粉:D),问题得以解决:
    cat .git/logs/HEAD     //能够看到提交的结果,一样能够用 git reflog 或 git log -g 命令查看到历史提交记录。
经过 git log -g 查看到全部提交记录,找到你要恢复的 commitid,即第一行 commit后面的那一大串字符,使用如下命令恢复到recover_branch:
    git branch recover_branch commitid
再用git branch 便可看到本地有两个branch了:
        master

    *  recover_branch
参考资料:
从Git仓库中恢复已删除的分支或丢失的commit
git常见问题和操做 php

二、在本地建立tag的方法是 git tag v1.0.0 ,可是这样github上并不能显示你的tag,因此须要输入下列命令以同步tag:
    git push origin --tags git

相关文章
相关标签/搜索