您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
39 禁止向集成分支执行push ...
发布时间:2020-08-01 18:04:54编辑:雪饮阅读()
有时候我们无法push成功还可以用push -f,这样就可以push成功,但也有其危害,我们先看看我这里一个仓库的一个分支目前的日志树
那么我查看下本地日志树
假设我本地要重置到箭头所指向的位置
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/moral (test34)
$ git reset --hard a53d498
HEAD is now at a53d498 C:/Users/xy/project/pwa3/dist/js C:/Users/xy/project/pwa3/dist/favicon.ico C:/Users/xy/project/pwa3/dist/index.html C:/Users/xy/project/pwa3/dist/manifest.json C:/Users/xy/project/pwa3/dist/precache-manifest.e8e73119b8fa65dc25182e8e58562d0c.js C:/Users/xy/project/pwa3/dist/robots.txt C:/Users/xy/project/pwa3/dist/service-worker.js C:/Users/xy/project/pwa3/dist/css C:/Users/xy/project/pwa3/dist/img
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/moral (test34)
我们发现本地重置以后就只有这么几条日志了
$ git log --oneline
a53d498 (HEAD -> test34) C:/Users/xy/project/pwa3/dist/js C:/Users/xy/project/pwa3/dist/favicon.ico C:/Users/xy/project/pwa3/dist/index.html C:/Users/xy/project/pwa3/dist/manifest.json C:/Users/xy/project/pwa3/dist/precache-manifest.e8e73119b8fa65dc25182e8e58562d0c.js C:/Users/xy/project/pwa3/dist/robots.txt C:/Users/xy/project/pwa3/dist/service-worker.js C:/Users/xy/project/pwa3/dist/css C:/Users/xy/project/pwa3/dist/img
5a0cbdf Update index.md
7b60a5a Set theme jekyll-theme-cayman
那么我们接下来要push到远端
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/moral (test34)
$ git push
To github.com:xueyin220807/moral.git
! [rejected] test34 -> test34 (fetch first)
error: failed to push some refs to 'git@github.com:xueyin220807/moral.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
发现直接push是无法push成功的,那么我们试试-f
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/moral (test34)
$ git push -f
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:xueyin220807/moral.git
+ 60ef560...a53d498 test34 -> test34 (forced update)
我们发生用-f后就能够成功push了,但接下来我们看看我们远端的日志树
是吧,悲剧了吧,过往的日志都不见了,这个时候如果一个新的成员加入并检出我们的项目就会发现我们的项目基本就算是0的阶段。。。
关键字词:git,push,push -f,-f,强制,f