push代碼死活push不上去。折騰了不少。出了不少問題。結果用最簡單的辦法解決了。java
代碼終於寫完,dome也寫了,單元測試也過了,很是高興,準備提交git
git push xxx xxx/dev-v1.0.1 T otal 0 (delta 0), reused 0 (delta 0) To ssh://gitlab.xxxx.cn:xx/xxx/gateway.git ! [remote rejected] xx/dev-v1.0.1 -> xxx/dev-v1.0.1 (deny updating a hidden ref) error: failed to push some refs to 'ssh://git@gitlab.xxx.cn:xxx/xxxx/gateway.git'
555555555555,提交不上去..... 寶寶的高興勁被熄滅了...shell
git pull --rebase origin master
遠程庫與本地庫同步。app
git push origin HEAD:master
肯定上傳分支,一本默認爲master,這一步便可,不行試試下一步再上傳。dom
git push -u origin master
嗯,目前好了。ssh
寫了不少代碼,須要提交另一個遠程服務,上面百度的方法失效了gitlab
第一步pull就失敗了,後續兩步也嘗試了無效。單元測試
dell@DESKTOP-9UF9FEN /xxxx/work/xxx/gateway (detached HEAD|REBASE 5/16) git pull --rebase xxxx dev-v1.0.1 From ssh://gitlab.xxxx.cn:xxxx/xxxx/gateway * branch dev-v1.0.1 -> FETCH_HEAD It seems that there is already a rebase-apply directory, and I wonder if you are in the middle of another rebase. If that is the case, please try git rebase (--continue | --abort | --skip) If that is not the case, please rm -fr "D:/work/xxx/xxxx/.git/rebase-apply" and run me again. I am stopping in case you still have something valuable there.
git status 也無效測試
git status HEAD detached at xxxxx/dev-v1.0.1 nothing to commit, working tree clean
這個解決能夠用,下面的命名解決lua
git rebase --abort
由於本地代碼比遠程的代碼多幾個提交,執行git pull --rebase 遠程代碼把本地代碼覆蓋了..悲劇。哎!!! 立刻想到回滾到最近的提交
git log commit 200b6141a884989124009487fa90deb776e2d047 (HEAD) Author: liukang <xxx@xxx.com> Date: Fri Sep 27 10:22:02 2019 +0800 add: 一、新增常量 xxxxx commit bcd2ed304174064539291dcb028cfcae3579a169 Author: liukang <xx@xxx.com> Date: Fri Sep 27 10:19:53 2019 +0800 add: 一、新增批量登記數據接口 git reset --hard 200b6141a884989124009487fa90deb776e2d047
結果發現代碼仍是沒有......
第一步執行 git reflog
git reflog 200b614 (HEAD) HEAD@{0}: pull --rebase xxx dev-v1.0.1: add: bcd2ed3 HEAD@{1}: pull --rebase xxx dev-v1.0.1: add: 3e585df HEAD@{2}: pull --rebase xxx dev-v1.0.1: add: 88c6b64 HEAD@{3}: pull --rebase xxx dev-v1.0.1: add: 5fcacb6 (xxxx/dev-v1.0.1, master, dev-1.0.1) HEAD@{4}: pull --rebase xxxx dev-v1.0.1: checkout 5fcacb6d64f0562cc796d16dd7f9dd2e9407c904 3ed474f HEAD@{5}: rebase: updating HEAD 1796d7f HEAD@{6}: commit (merge): pull 最新代碼 3ed474f HEAD@{7}: reset: moving to 3ed474f 5fcacb6 (xxxxx/dev-v1.0.1, master, dev-1.0.1) HEAD@{8}: reset: moving to 5fcacb6 3ed474f HEAD@{9}: reset: moving to 3ed474f e4c2b62 HEAD@{10}: reset: moving to e4c2b62 3ed474f HEAD@{11}: reset: moving to 3ed474f 5fcacb6 (xxxxx/dev-v1.0.1, master, dev-1.0.1) HEAD@{12}: checkout: moving from 2713bf28e9d15541f022846eaf3a8d80a3074c8c to laohu/dev-v1.0.1 2713bf2 (origin/dev-v1.0.1) HEAD@{13}: checkout: moving from 63cbda1fcd160ae381a5c436fbf4d4a114e2ffb5 to origin/dev-v1.0.1 63cbda1 HEAD@{14}: reset: moving to 63cbda1fcd160ae381a5c436fbf4d4a114e2ffb5 3c8ecb3 HEAD@{15}: reset: moving to 3c8ecb3ca430ac05f4d0a3c48db8fdac53417e2e 76c47a1 HEAD@{16}: commit: 處理衝突 3c8ecb3 HEAD@{17}: commit: 解決更新問題
第二步執行 git reset --hard 【 找第一列的id, 1796d7f HEAD@{6}: commit (merge): pull 最新代碼 。id爲 1796d7f】
git reset --hard 1796d7f
當執行 git pull --rebase origin master,有這樣的提示
dell@DESKTOP-9UF9FEN /xxxx/work/xxx/gateway (detached HEAD|REBASE 5/16)
重點:detached HEAD|REBASE 5/16
重點:detached HEAD|REBASE 5/16
重點:detached HEAD|REBASE 5/16
detached表示當前分支處理遊離狀態,意識是當前分支是直接在遠程分支上進行操做的,沒有與本地分支進行關聯。解決detached狀態就能夠提交了。
第一步 經過建立臨時分支解決分支的detached狀態
git checkout -b new_tmp Switched to a new branch 'new_tmp'
第二步 切換到須要push的遠程分支
git checkout xxxx/dev-v1.0.1 Note: checking out 'xxxx/dev-v1.0.1'.
第三步 建立本地分支
git checkout -b dev-v1.0.1 Switched to a new branch 'dev-v1.0.1'
第四步 把臨時分支的代碼合併到本地分支
git merge new_tmp Updating 5fcacb6..1796d7f
第五步 push代碼到遠程分支
git push xxxx dev-v1.0.1
每次pull遠程分支,立馬建立本地分支,在本地分支上開發,就不遇到detached問題,就不會出現上面的問題
detached的問題之前也出現過,簡單的百度解決以後,沒有探求根源。總是反覆的出現一樣的問題。今天探求了detached的根源,之後再出現detached的問題,能簡單的解決了
PS: 吾' 探求根源