【问题标题】:How to commit files from a local folder named differently in the remote folder?如何从远程文件夹中不同名称的本地文件夹提交文件?
【发布时间】:2014-07-06 03:20:59
【问题描述】:

Firefox 有一个 profile folder(它有一个随机名称,例如 r2hy5dsu.default)。

如果安装了Greasemonkey,则会在该文件夹中创建一个名为gm_scripts 的文件夹。
配置文件文件夹包含许多其他文件和文件夹,但现在对我来说唯一重要的是 gm_scripts

所以,我想创建一个名为 reponameX(与 r2hy5dsu.default 不同)的存储库,其中包含一个名为 dirY(与 gm_scripts 不同)的文件夹,其中包含后者的内容,但我没有不知道这是否可能。

LOCAL                                     GITHUB
r2hy5dsu.default                  <-->    reponameX
+ gm_scripts                      <-->    + dirY
+ + ... (a lot of other things)   <-->    + + (I want to sync everything here)
+ ... (a lot of other things)     <-->    + (I don't want to sync it at all)

我的问题是:这可能吗?如果是这样,我该如何做到这一点?

到目前为止,我found 的所有内容都是如何创建一个与本地文件夹名称不同的存储库,但第二部分没有。

这样,它可以帮助我轻松发布和更新我自己开发和测试的所有脚本,而不必为了提交它而复制到其他地方。

【问题讨论】:

  • 您的原始问题在被问到后不久显然被否决了。这意味着像我这样的订阅者没有看到它,并且活动仍然很低。一个月后自动删除负分和低活动(包括没有答案)的问题,有趣,是吗?现在,您可能想从这个问题中删除元杂乱。
  • 有趣的问题。我所做的是将我的@downloadURL 指令设置为文件的发布版本/位置。 GM auto 会在检查更新时获取更改。我承认我使用剪切和粘贴来快速开发。自己可以使用更好的集成,但没有花时间解决。
  • 您可以使用 Firefox 的配置文件管理器,使用您想要的任何文件夹创建 Firefox 配置文件。事实上,为各种测试配置分别配置配置文件是件好事。
  • 另外,Q 的提交方法仅在初始安装脚本之后 有效。您不能只在该文件夹中放置一个新脚本(我上次检查过)并由 Greasemonkey 运行它。
  • 我目前的问题是 gm_scripts 不能在 repo 中以不同的方式命名,比如 dirY。至少,不是我所知道的。如问题中所述。

标签: git firefox github greasemonkey


【解决方案1】:

从长远来看,最干净的方法是直接构建一个边带分支,这根本不会影响您当前的结帐:

#!/bin/sh
# Using only a temporary index file,
# Without touching the current checkout or using a worktree at all,
# Commit a hand-rolled commit to an arbitrary branch

$srctree=`git write-tree` # current status, `somecommit` elsewise

export GIT_INDEX_FILE=`mktemp -t`
git read-tree $srctree                    # load up the nonce index

git read-tree --prefix=dirY/ :gm-script   # load `dirY/` from indexed `gm-script`
git rm --cached gm-script                 # remove indexed `gm-script`

tip=`git rev-parse -q for-github -- 2>&-` # commit to the tip of `for-github`
git update-ref refs/heads/for-github \
    $( git commit-tree ${tip:+-p $tip} \
               -m handroll `git write-tree`
    )

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-30
    • 2013-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    相关资源
    最近更新 更多