小众GIT

作者: 一只重拾梦想的小水 | 来源:发表于2019-08-02 11:51 被阅读0次

    1、git reflog: 操作记录,找回reset等误操作

    2、git rebase --todo

    3、git submodule:

    参考:https://codewinsarguments.co/2016/05/01/git-submodules-vs-git-subtrees/

    a. 解决了什么问题
    需要用到公共类库 library
    类库特点:业务相关&公用
    即有与业务代码一起开发的需要(为什么不用npm:npm包需要频繁发包更新版本),又要在多个项目中可共用

    参考:http://www.ayqy.net/blog/%E7%90%86%E8%A7%A3git-submodules/

    b. 对比subtree:

    简而言之:
    • Submodules are easier to push but harder to pull – This is because they are pointers to the original repository
    • Subtrees are easier to pull but harder to push – This is because they are copies of the original repository
    分开来讲:
    • Submodules:
      适用:
      Need to push frequently
      本质:
      a submodule is nothing but a pointer to a specific commit in an external repository
      **issues: **
      1.Changes to the parent could be committed and pushed without having committed and pushed the changes to the submodule. (to commit&push sub+commit&push super)
      2.If a collaborator has modified and pushed changes to a submodule but you haven’t run git submodule update to update the submodule on your machine to their latest version, you may run git add -A and downgrade to your out of date version.( to git submodule update )
      issue eg:
    Git commit sub(without push)
    git commit&push super
    // Clone repo: 
    Git pull super
    git submodule update
    
    without push subproject
    golden rule
    Always commit and push the submodule changes first, before then committing the submodule change in the parent repository.
    Tips:
    If you define an alias which runs git submodule update after every single git pull then you will be safe, but a newbie is unlikely to do this.
    • Subtree:
      适用:No need to push ( then why not npm? npm不提供源码细节 )
      注意:there will be nothing in the dir to indicate that the folder ever came from another git repository.
      issues:
      1.So slow in a large repository on Windows
      2.very little documentation

    相关文章

      网友评论

          本文标题:小众GIT

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