如何在git';什么是contrib目录?

如何在git';什么是contrib目录?,git,Git,Git包括一个。我不知道该如何正确使用这些工具 例如,我想使用。我似乎有很多方法可以使用它: 复制到我的路径 cp /path/to/git-subtree.sh /usr/local/bin/git-subtree chmod +x /usr/local/bin/git-subtree chmod +x /path/to/git-subtree.sh ln -s /path/to/git-subtree.sh /usr/local/bin/git-subtree 工作正常,感觉有点不舒服

Git包括一个。我不知道该如何正确使用这些工具

例如,我想使用。我似乎有很多方法可以使用它:

  • 复制到我的路径

    cp /path/to/git-subtree.sh /usr/local/bin/git-subtree
    chmod +x /usr/local/bin/git-subtree
    
    chmod +x /path/to/git-subtree.sh
    ln -s /path/to/git-subtree.sh /usr/local/bin/git-subtree
    
    工作正常,感觉有点不舒服

  • 符号链接到我的路径

    cp /path/to/git-subtree.sh /usr/local/bin/git-subtree
    chmod +x /usr/local/bin/git-subtree
    
    chmod +x /path/to/git-subtree.sh
    ln -s /path/to/git-subtree.sh /usr/local/bin/git-subtree
    
    同样有效,感觉稍微不那么粗糙

  • 使用git别名

    将以下内容添加到我的global.gitconfig文件中:

    [alias]
        subtree = !/path/to/git-subtree.sh
    
    那好老天爷又来了:

    chmod +x /path/to/git-subtree.sh
    
    工作起来,感觉很好,很傻

  • 使用Makefile

    根据

    对我不起作用,它试图安装到一个不存在的路径。也许这是因为我是使用而不是从源代码安装git的?我懒得去调查;我已经有了三个工作选择:


  • 所以我的问题是,安装git contrib附加组件的首选方法是哪种?还有更好的方法吗?有没有比上面列出的更好的选择呢?

    Contribs是一个有用的东西的集合。您不能将它们作为软件包安装。例如,要安装tab completion,只需从.bash_配置文件脚本中获取该脚本的源代码。该文件夹中的每个contrib都有自己的使用方式

    至于从源代码编译git

    make
    sudo make install
    

    安装所有必备组件后。

    从git/contrib/git子树:

    如何安装git子树
    ==========================

    首先,从顶级源目录构建

    然后,在contrib/子树中运行:

     make
     make install
     make install-doc
    
    如果您使用configure进行主构建,git子树构建将 选择那些设置。如果没有,您可能需要提供 前缀的值:

     make prefix=<some dir>
     make prefix=<some dir> install
     make prefix=<some dir> install-doc
    
    然后:

     make test
    
    我刚刚验证了这一点:

  • 通过现有git下载源代码
  • 已安装的生成deps

    $ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev
    
    sudo apt-get remove -y libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev asciidoc
    sudo apt-get autoremove -y
    
  • 查看最新版本的分支和构建

    $ git co v1.7.11.3  
    $ make prefix=/usr/local all  
    $ sudo make prefix=/usr/local install  
    
  • 构建并安装contrib/子树

    $ cd contrib/subtree  
    $ make  
    $ make install  
    $ make install-doc   
    
  • 确认一切正常

    /usr/local/bin/git  
    [todd@montreal-01 subtree ((v1.7.11.3))]$ git --version  
    git version 1.7.11.3  
    
  • 检查,我们有最新的git

    [todd@montreal-01 subtree ((v1.7.11.3))]$ git subtree  
    usage: git subtree add   --prefix=<prefix> <commit>  
        or: git subtree merge --prefix=<prefix> <commit>  
        or: git subtree pull  --prefix=<prefix> <repository> <refspec...>  
        or: git subtree push  --prefix=<prefix> <repository> <refspec...>  
        or: git subtree split --prefix=<prefix> <commit...>
    
        -h, --help            show the help  
        -q                    quiet  
        -d                    show debug messages  
        -P, --prefix ...      the name of the subdir to split out  
        -m, --message ...     use the given message as the commit message for the merge commit  
    
    options for 'split'  
        --annotate ...        add a prefix to commit message of new commits  
        -b, --branch ...      create a new branch from the split subtree  
        --ignore-joins        ignore prior --rejoin commits  
        --onto ...            try connecting new tree to an existing one  
        --rejoin              merge the new branch back into HEAD  
    
    options for 'add', 'merge', 'pull' and 'push'  
        --squash              merge subtree changes as a single commit  
    
    [todd@montreal-01子树((v1.7.11.3))]$git子树
    用法:git子树添加--前缀=
    或:git子树合并--前缀=
    或:git子树拉取--前缀=
    或:git子树推送--前缀=
    或:git子树拆分--前缀=
    -h、 “帮助”表示帮助
    -q安静
    -显示调试消息
    -P、 --前缀。。。要拆分的子曲面的名称
    -m、 --消息。。。使用给定消息作为合并提交的提交消息
    “拆分”选项
    --注释。。。添加前缀以提交新提交的消息
    -b、 --分行。。。从拆分子树创建新分支
    --忽略连接忽略优先级--重新连接提交
    --到。。。尝试将新树连接到现有树
    --重新连接将新分支合并回HEAD
    “添加”、“合并”、“拉”和“推”选项
    --将合并子树更改压缩为单个提交
    
    检查,我们有子树工作。

    一个命令中包含以下所有内容,仅在Ubuntu中测试: 现在,这里介绍如何在ubuntu中安装最新的git,并将git作为一个包 要将其作为一个包(首选):

    如果不安装AsciDoc,请忽略下面带有make target“install doc”的行

    这将签出主/最新标记版本,并将其作为软件包安装

    git clone https://github.com/git/git.git
    cd git
    make prefix=/usr/local all
    sudo checkinstall --pkgname=git make prefix=/usr/local install
    
    然后承包商:

    cd contrib/subtree
    make prefix=/usr/local
    sudo checkinstall --pkgname=git-subtree make prefix=/usr/local install
    
    …对是否从主文件夹中排除文件的问题回答
    yes
    y

    sudo checkinstall --pkgname=git-subtree-doc make prefix=/usr/local install-doc
    
    …对是否从主文件夹中排除文件的问题回答
    yes
    y

    sudo checkinstall --pkgname=git-subtree-doc make prefix=/usr/local install-doc
    
    您现在可以处理git包:

    dpkg -r git
    
    和子树包:

    dpkg -r git-subtree
    dpkg -r git-subtree-doc
    
    如果您不想让5G的latex perl脚本占用硬盘空间,请执行以下操作:

    sudo apt-get remove asciidoc -y
    sudo apt-get autoremove -y
    
    全部(所有构建部门)

    感谢@toddg提供了我需要的基本命令


    我还没能制作git子树--“帮助”查找正确的手册页。

    以下是对我来说最简单的一件事,在Ubuntu 12.10上安装git子树:

    获取代码

    git clone https://github.com/git/git.git --depth=1
    cd git/contrib/subtree
    make
    
    将其“安装”到git tools目录中

    sudo cp git-subtree /usr/lib/git-core/
    
    对于手册页,您需要asciidoc,它不是一个小型安装,但如果您有:

    make doc
    gzip git-subtree.1
    sudo cp git-subtree.1.gz /usr/share/man/man1
    

    就这样。

    所有这些看起来都比必要的要复杂一些。
    (可能是因为install.sh是最近添加的?
    这就是我的工作。至少看起来是这样

    # go to a directory where it's ok to put temporary stuff
    cd ~
    git clone git://github.com/apenwarr/git-subtree.git
    cd git-subtree/
    # shell script does the job for you.
    sudo sh ./install.sh
    cd ..
    # remove the git cloned stuff, now that all relevant things have been copied (we hope)
    rm -r git-subtree
    
    # test that it works
    git subtree
    # should print some help/usage stuff.
    
    有一条说明主要是这样说的:

    我比那更蠢一点。我需要被告知,在运行shell脚本之前,我必须将(git clone)东西下载到任意位置,然后才能处理这些东西

    install.sh的内容很有启发性,


    如果你想安装一个本身不提供install.sh的git thingie,这可能是一个开始。

    谢谢Adam,这很有意义。没关系,我知道如何从源代码安装git,我只是太懒了很简单,懒惰不是借口p您还可以将
    路径
    变量指向git contrib的东西。它可以工作!谢谢这是关键:
    makeprefix=/usr/localall
    。我以前做过git的普通make安装,但子树安装失败。一个小的遗漏:我在为子树执行
    makeinstalldoc
    时缺少了一个额外的依赖项
    asciidoc
    。另外,当没有阅读您对安装过程的描述时,从git文档中不清楚是否要在git项目之前安装和构建子树contrib项目。我感到困惑。如果您已经安装了(最新版本的)git,为什么需要从头开始编译以使用contr中的某些内容
    # go to a directory where it's ok to put temporary stuff
    cd ~
    git clone git://github.com/apenwarr/git-subtree.git
    cd git-subtree/
    # shell script does the job for you.
    sudo sh ./install.sh
    cd ..
    # remove the git cloned stuff, now that all relevant things have been copied (we hope)
    rm -r git-subtree
    
    # test that it works
    git subtree
    # should print some help/usage stuff.