github

作者: 了尘兰若 | 来源:发表于2019-04-01 08:46 被阅读0次

    1. 创建tag

    git tag v1.0.0 -m 'first version'

    上传到github

    git push origin v1.0.0

    存档某个tag

    git archive -v --format=tar v1.0.0 > v1.0.0.tar.gz

    2. 上传大于100M的文件

    需要用到git-lfs,安装方法见其官网,在此不赘述。

    上传分两种情况(2.1 & 2.2)。亲身体验,2.1失败了,2.2成功上车,所以,可以先将大文件push一遍,再采用2.2的方式来操作是极好的。

    2.1 如果大文件不存在于repository提交历史中,可通过“git lfs track”追朔它们。

    # 告知Git LFS哪些文件需要其管理(此处有2个大文件):

    $ git lfs track COG_2014.psq

    $ git lfs track cog2003-2014.csv

    Tracking "cog2003-2014.csv"

    # Track之后,添加文件(带路径),并提交的修改

    $ git add Functions/COG/COG_2014.psq

    $ git add Functions/COG/cog2003-2014.csv

    $ git commit -m "track cog2003-2014.csv and COG_2014.psq using Git LFS"

    [master 2b526f9] track cog2003-2014.csv and COG_2014.psq using Git LFS 2 files changed, 1962232 insertions(+)

    create mode 100644 Functions/COG/COG_2014.psq

    create mode 100644 Functions/COG/cog2003-2014.csv

    # 上传到 Github

    $ git push origin master

    Username for 'https://github.com': liaochenlanruo

    Password for 'https://liaochenlanruo@github.com':

    Username for 'https://github.com': liaochenlanruo

    Password for 'https://liaochenlanruo@github.com':

    Username for 'https://github.com': liaochenlanruo

    Password for 'https://liaochenlanruo@github.com':

    Counting objects: 3, done.

    Delta compression using up to 8 threads.

    Compressing objects: 100% (3/3), done.

    Writing objects: 100% (3/3), 369 bytes | 184.00 KiB/s, done.

    Total 3 (delta 1), reused 0 (delta 0)

    remote: Resolving deltas: 100% (1/1), completed with 1 local object.

    To https://github.com/liaochenlanruo/pcgap.git

      a8c3687..46647d5  master -> master

    2.2 如果大文件已经存在于repository提交历史中,则“git lfs track”无法追朔它们。

    # 查看repository内的文件信息:

    $ cd “your repository”

    $ git lfs migrate info

    Username for 'https://github.com': liaochenlanruo

    Password for 'https://liaochenlanruo@github.com':

    migrate: Fetching remote refs: ..., done

    Username for 'https://github.com': liaochenlanruo

    Password for 'https://liaochenlanruo@github.com':

    migrate: Sorting commits: ..., done

    migrate: Examining commits: 100% (1/1), done

    *.phr  293 MB  1/1 files(s)    100%

    *.pin  14 MB  1/1 files(s)    100%

    *.tab  262 KB  2/2 files(s)    100%

    *.pl    59 KB  4/4 files(s)    100%

    *.py    5.4 KB  1/1 files(s)    100%

    # 将历史中已经存在的大文件迁移到Git LFS中(多个文件可用英文“,”分割):

    $ git lfs migrate import --include="*.phr"

    Username for 'https://github.com': liaochenlanruo

    Password for 'https://liaochenlanruo@github.com':

    migrate: Fetching remote refs: ..., done

    Username for 'https://github.com': liaochenlanruo

    Password for 'https://liaochenlanruo@github.com':

    migrate: Sorting commits: ..., done

    migrate: Rewriting commits: 100% (1/1), done

      master        a0806a20154f32f5c8a6f70e0647d48e8de8f609 -> a8c36870ea607f6e987b240a89bedc6b3a2faf2d

    migrate: Updating refs: ..., done

    migrate: checkout: ..., done

    # 确保目标大文件已经被 Git LFS is 接管:

    $ git lfs ls-files

    ece8c6236f - Functions/COG/COG_2014.phr

    # 将文件推送到Github:

    $ git push origin master

    Username for 'https://github.com': liaochenlanruo

    Password for 'https://liaochenlanruo@github.com':

    Username for 'https://github.com': liaochenlanruo

    Password for 'https://liaochenlanruo@github.com':

    Username for 'https://github.com': liaochenlanruo

    Password for 'https://liaochenlanruo@github.com':

    Git LFS: (1 of 1 files) 279.29 MB / 279.29 MB

    Counting objects: 6, done.

    Delta compression using up to 8 threads.

    Compressing objects: 100% (5/5), done.

    Writing objects: 100% (6/6), 624 bytes | 89.00 KiB/s, done.

    Total 6 (delta 2), reused 0 (delta 0)

    remote: Resolving deltas: 100% (2/2), completed with 2 local objects.

    To https://github.com/liaochenlanruo/pcgap.git

      2637bba..a8c3687  master -> master

    3. 将本地仓库修改的内容推送到远程仓库

    $ git add “修改后的文件” 

    $ git commit -m "修改描述"

    $ git push origin master

    4. gh-pages

    创建:

    git init

    git checkout --orphan gh-pages

    删除:

    git checkout master

    git push origin --delete gh-pages

    相关文章

      网友评论

          本文标题:github

          本文链接:https://www.haomeiwen.com/subject/ddsubqtx.html