• git使用经验汇总


    git显示版本号

    git describe --tags

    ubuntu下.gitconfig内容

    [user]
            name = cd_tangxiaoshen_8227
            email = tangxiaosheng@yeah.net
            user = cd_tangxiaoshen_8227
    [cola]
            spellcheck = false
    [credential]
            helper = store

     用命令:git config credential.helper store,就把密码存下来了。.gitconfig增加了一项,[credential] ...

    git加速和只下载部分目录

    浅复制

    工作要用到的.git有1.8G太大了。下载过程要好几个小时,太慢了。可以这样操作

    git clone 默认会下载项目的完整历史版本,如果你只关心最新版的代码,而不关心之前的历史信息,可以使用 git 的浅复制功能:

    $ git clone --depth=1 https://github.com/bcit-ci/CodeIgniter.git
    --depth=1 表示只下载最近一次的版本,使用浅复制可以大大减少下载的数据量,例如,CodeIgniter 项目完整下载有近 100MiB ,而使用浅复制只有 5MiB 多,这样即使在恶劣的网络环境下,也可以快速的获得代码。如果之后又想获取完整历史信息,可以使用下面的命令:

    $ git fetch --unshallow

    对zadas我实际用的命令是:git clone --depth=1 http://shagit01.cn.zmt.local/ST/zadas.git

    用该命令还是没法得到分支 fusion_dev下的代码。

    断点续传的方法

    mkdir zadas

    cd zadas

    git fetch http://shagit01.cn.zmt.local/ST/zadas

    中间如果断了,就再执行一下 git clone ...

    直到fetch完毕后,出现以下字样

     From  http://shagit01.cn.zmt.local/ST/zadas.git

     *branch           HEAD                -> FETCH_HEAD

    然后用git checkout FETCH_HEAD

    或者也等同于git fetch  http://shagit01.cn.zmt.local/ST/zadas.git HEAD

    对这个方法需要持谨慎态度,因为我 git branch -r 显示远程分支,结果为空,实际是不对的。

    下载个别目录

    $ mkdir 文件夹名称

    创建一个空的本地仓库
    $ git init

    连接远程仓库GitHub
    $ git remote add -f origin <url>
    我的操作:$ git remote add -f origin https://github.com/aliyun/alicloud-android-demo.git
    然后控制台会显示一些updating...信息。注意,这里的url必须是.git结尾的。

    开启sparse checkout 模式
    $ git config core.sparsecheckout true

    告诉Git哪些文件或者文件夹是你真正想Check Out的
    (你可以将它们作为一个列表保存在 .git/info/sparse-checkout 文件中。)

    例如:
    $ echo libs >> .git/info/sparse-checkout

    最后一步,拉取想要的分支

    $ git pull origin master

  • 相关阅读:
    codeforces 764 C. Timofey and a tree(dfs+思维)
    codeforces 161 D. Distance in Tree(树形dp)
    codeforces 761 D. Dasha and Very Difficult Problem(二分+贪心)
    codeforces 761 C. Dasha and Password(多维dp)
    codeforces 264 B. Good Sequences(dp+数学的一点思想)
    HTML5 总结-画布-4
    HTML5 总结-拖放-3
    HTML5 总结-音频-2
    HTML5 总结-视频-1
    CSS3 总结-2
  • 原文地址:https://www.cnblogs.com/tangxiaosheng/p/10675824.html
Copyright © 2020-2023  润新知