git 中 出现your current branch appears to be broken错误
git 中 出现your current branch appears to be broken错误
1.死机导致的 Git 错误
原因为:IDEA崩了,使用git log 命令时候提示标题中错误,git status 提示正常 。
2. 解决方案,修复 .git/refs/heads/分支名
2.1 查找 .git/logs/refs/heads/分支名, 打开这个文件
2.2 查找 .git/logs/refs/heads/分支名, 打开这个文件找到最后一次 commit 的 commit-id
711fe2d55860cf1fb6d5c2a8867363ef29b372e8 eaf57a1fdde86d985340a993ceb9beadb7cf11f3 yanglin1501804006 <[email protected]******> 1593426173 +0800 commit: 整合半有缘的接口管理功能
这里的 commit-id 就是eaf57a1fdde86d985340a993ceb9beadb7cf11f3
2.3 用文本打开 ./git/refs/heads/分支名 , 将 commit-id 覆盖写入该文件
2.4 再次运行 git log, ok 正常了
3. 正常提交代码
$ git status
On branch B#yanglin02
Your branch is ahead of ‘origin/B#yanglin02’ by 94 commits.
(use “git push” to publish your local commits)
nothing to commit, working tree clean
3.1 git branch -vv
git branch -vv
- B#yanglin02 812065f01 [origin/B#yanglin02: ahead 94] Merge branch ‘B#zhoumei’ into ‘master’
master 061f17dd2 [origin/master: behind 282] Merge branch ‘b#modify_all_svc_port’ into ‘master’
查看自己本地开发分支与远程分支关系
3.2 git push origin B#yanglin02
$ git push origin B#yanglin02
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: To create a merge request for B#yanglin02, visit:
remote: http://IP地址/TIAP/tiap/merge_requests/new?merge_request%5Bsource_branch%5D=B%23yanglin02
remote:
To [IP地址]:TIAP/tiap.git
eaf57a1fd…812065f01 B#yanglin02 -> B#yanglin02
3.3 git status
$ git status
On branch B#yanglin02
Your branch is up to date with ‘origin/B#yanglin02’.
nothing to commit, working tree clean
这样就正常啦!