zoukankan      html  css  js  c++  java
  • git删除远程分支中的文件

    一开始没有把git项目中的.classpath加入到.gitignore中,导致远程分支中一直存在这个文件,这样在其他机器上执行git pull时,会导致本地的.classpath被破坏,而使得这个项目的引用出现问题。由此,我们需要把远程分支中的.classpath文件删除。
    1. 一种想法是把.classpath文件加入到gitignore中,这样在下次提交的时候就不会提交.classpath文件,但是这种做法并不会使得远程分支中的.classpath文件被删除。
    2. 下面有比较挫的方法来解决:
    在本地项目中先把 classpath移出到git仓库之外的一个位置,相当于在git 仓库中把classpath文件删除了;
    mv cps/.classpath ..
     
    修改gitignore文件,加入 *.classpath这一项,
    提交删除了classpath的版本,发现远程分支中的文件已经被删除了。
    1 git add --all .
    2 git commit -m "update gitignore"
    3 git push origin master
     
    把被移除的.classpath文件移回到项目中,此时如果再提交,因为classpath已经被加入到gitignore中了,那么就不会重新提交classpath文件了。
    mv ../.classpath cps/



  • 相关阅读:
    android 限定符参考
    Fragment生命周期
    碎片和活动之间通信
    Fragment碎片的使用
    使用Intent传值及回传值
    Calendar 获取年 月 日 时 分 秒
    Python函数:2018-07-30
    Python 字符串 2018-07-27
    Python 异常 2018-08-01
    __future__ 模块 2018-08-09
  • 原文地址:https://www.cnblogs.com/jing77jing/p/4821045.html
Copyright © 2011-2022 走看看