zoukankan      html  css  js  c++  java
  • git使用

    1. 向一个远程仓库添加本地目录,作为一个新分支, 基本参考这里操作:

    git init 
    git add  xx
    git commit -m "init"
    git remote add origin http:/xxx.git
    git branch newbranch
    git checkout newbranch
    git push --set-upstream origin newbranch

    2. 向一个已存在的git上添加其他目录:

    1 git init
    2 git remote add xxx https://git.xxx.com/xxx/xxx.git
    3 git add xx
    4 git commit -m "xxx"
    5 git pull https://git.xxx.com/xxx/xxx.git
    6 git push cropdata master

    3. 远程仓库相关问题

    3.1 git基础-远程仓库的使用

    3.2 重定位远程地址

    git remote set-url origin https://github.com/xxx/xxx.gitt

    3.3 一个本地仓库对应两个远程地址

    git remote add gitee https://gitee.com/tszs_song/test.git
    git remote add github https://github.com/tszssong/test.git
    git push --set-upstream gitee master
    git push --set-upstream github master

    执行 git remote -v 应有如下结果:

    3.3 删除一个远程仓库:

    git remote rm github

    3.4 修改了本地文件后无法提交也无法pull:

         error: The following untracked working tree files would be overwritten by merge:

    git clean -i
    git pull
    git push

     3.5 远程删除分支后本地同步:

    git fetch -p

    4. git 子模块,如果clone时有子模组克隆失败,可以用以下命令:

    git submodule update --init --recursive

    ------------------2018.12.05-----------------------------------

    删除不小心加进去了几个大的log文件

    git filter-branch --force --index-filter  'git rm -rf --cached --ignore-unmatch  examples/hand_reg/alimouth/log/xxx.log' --prune-empty --tag-name-filter cat -- --all

    有好几个大的log超过100M, 超出了github的最大文件限制,貌似需要一条一条的删;阿里云上删除一条需要20多分钟,开了几个窗口同时删除报错如下:

    fatal: Unable to read current working directory: No such file or directory
    Cannot read commit a17ea59e90a41fa8490b65f63e31a3ee1633a50f
    rm: cannot remove '/nfs/zhengmeisong/wkspace/gesture/caffe/.git-rewrite': Directory not empty

    一条一条执行没问题。全部删除以后git pull git push执行一遍就好了;

    忽略不想添加到git的文件

    vi .gitignore

    在该文件末尾添加不想添加的文件或路径

    gitignore失效的解决:  已经加入了git的文件需要先删除本地缓存

    git rm -r --cached .
    git add .
  • 相关阅读:
    springIOC 原理
    jeesite异步分页
    yum
    乐观锁原理
    equlas(),hashcode(),hashset,hashmap
    链接收藏
    java单词
    jeesite优化
    SailingEase .NET Resources Tool (.NET 多语言资源编辑器)转
    C#基本语法
  • 原文地址:https://www.cnblogs.com/zhengmeisong/p/9383367.html
Copyright © 2011-2022 走看看