zoukankan      html  css  js  c++  java
  • git删除远程分支文件,不改变本地文件

    git提交项目时候踩的Git的坑

    特别

    由于准备春招,所以希望各位看客方便的话,能去github上面帮我Star一下项目
    https://github.com/Draymonders/Campus-Shop

    经历

    由于刚开始没有设置.gitignore文件,导致项目中所有的文件都被提交到了github上面,由此带来的问题就是有些debug日志也被提交了上去,对于团队开发很不友好。

    一个错误的尝试

    git rm -r --cached "fileName/directionName"
    

    执行这个,发现文件里面有.等特殊字符的就会报错

    fatal: pathspec '.settings/' did not match any files
    

    最后的解决方案

    没办法
    只能把一些没用的文件,暂时移动到回收站
    然后分别执行

    git add .
    git commit -m "delete some files that others do not need"
    git push -u origin master
    

    如果还是有问题的话

    git提供了很好的回滚机制,如果回滚到了远程库之前的版本,那么提交的时候 记得要-f参数

    git log
    git reset --hard b262ba9678b3aa4ed79e463b3a5e21398419eb56
    git status
    git add .
    git commit -m "delete some files that others do not need"
    git push -f origin master
    
  • 相关阅读:
    关于树状数组区间最值
    Gym 100500B
    RQNOJ Bus
    关于加权的LIS问题
    vs tip1
    小常识
    我的魔方主力
    killer驱动
    从日升的mecha anime看mecha genre的衰退
    关于供给移动端的视频压制
  • 原文地址:https://www.cnblogs.com/Draymonder/p/10198509.html
Copyright © 2011-2022 走看看