git 一直无法push的解决办法

来源:互联网 发布:空白网名软件 编辑:程序博客网 时间:2024/05/16 08:32

情况是这样的,我在修改完本地的代码之后 执行 add   commit 这个时候应该可以push,然后我push了一下,然后命令行告诉我并没有修改任何内容,然后我刷新我的github的仓库也没有反应,的确push 失败了,然后我就再次重复上面的步骤 一次,发现还是不行,但是步骤并没有错,而且内容的确修改了,然后我git status了一下 这是显示的状态:

$ git statusHEAD detached from b735284nothing to commit, working directory clean
然后我看了一下远程库中的版本的确是 b735284 ,然后我通过checkout修改了一下head还是不行,还是有这个问题,最后我在googlg上看到了一个外国大牛的解决办法,其实是我的分支出了问题,一试就成功了:  原文链接

$ git commit rear-release-notes.txt# HEAD detached from rear-1.16

I had now commits in a branch named:

$ git branch* (detached from rear-1.16)  master

Ok, so I went back to the master branch:

$ git checkout masterWarning: you are leaving 2 commits behind, not connected toany of your branches:  e9abc7a push release notes 1.16 (again)  2f5d3fd adding the release notes for 1.16 to doc/If you want to keep them by creating a new branch, this may be a good timeto do so with: git branch new_branch_name e9abc7aSwitched to branch 'master'

Then I executed the following steps with a temporary branch temp to get the missing commits back into the master branch.

$ git branch temp e9abc7a$ git checkout tempSwitched to branch 'temp'$ git branch  master* temp$ git log --graph --decorate --pretty=oneline --abbrev-commit master origin/master temp* e9abc7a (HEAD, temp) push release notes 1.16 (again)* 2f5d3fd adding the release notes for 1.16 to doc/* 4581e52 (tag: rear-1.16, origin/master, origin/HEAD, master) prepare rear for new release 1.16*   de337d4 Merge pull request #403 from ypid/df-encfs-fix$ git diff master tempdiff --git a/doc/rear-release-notes.txt b/doc/rear-release-notes.txt....$ git diff origin/master tempdiff --git a/doc/rear-release-notes.txt b/doc/rear-release-notes.txt....$ git branch -f master temp$ git checkout masterSwitched to branch 'master'Your branch is ahead of 'origin/master' by 2 commits.  (use "git push" to publish your local commits)$ git push$ git branch -d tempDeleted branch temp (was e9abc7a).


0 0
原创粉丝点击