我如何在Windows上的git附件中提交(调整后的分支)



我在不支持符号链接的文件系统上有一个gitgit annex项目。因此,我必须使用调整后的分支,这意味着在我的";正常的";分支我执行git annex adjust --unlock,这样我就得到了一个新的分支,在这个分支上,我的附件文件不是指向附件存储的符号链接,而是原始文件。我的提交树看起来是这样的:

*  git-annex adjusted branch (HEAD, adjusted/master(unlocked))
* ┘ some change (master, refs/basis/adjusted/master(unlocked))
* some prior change
...

当我现在提交时,我想我会在调整后的分支上这样做,因为git附件无法使用git annex add MYFILE和git commit`创建符号链接:

* my new commit (HEAD, adjusted/master(unlocked))
*  git-annex adjusted branch 
* ┘ some change (master, refs/basis/adjusted/master(unlocked))
* some prior change

我想要的是以标准git附件格式提交到master分支,这意味着附件文件是指向它们在附件存储中位置的符号链接。最后,因为我无法在文件系统中签出符号链接,所以我需要自动创建一个新的调整后的分支,用实际文件替换提交中的符号链接。

那么我该如何从上面的情况发展到下面的情况呢:

*  git-annex adjusted branch (HEAD, adjusted/master(unlocked))
* ┘ my new commit (master, refs/basis/adjusted/master(unlocked))
│ *  git-annex adjusted branch (abandoned previous HEAD)
* ┘ some change
* some prior change

关于git附件调整的git附件手册只告诉我如何获得调整后的分支,但没有告诉我如何反向调整。调整概念页面对我来说有点神秘(突出显示的文本是我的(。

用户在调整后的分支上的提交必须反向调整为获取要应用于master分支的更改。

一种调整的逆转可以作为另一种调整来完成调整由于只有被提交所触及的文件才会被反转调整后,它不需要反转原始文件所做的所有更改调整当我的文件系统不支持符号链接时,我应该如何从文件反向调整到符号链接?]

例如,反转解锁调整可能会锁定文件。或它可能什么都不做,这会使所有提交的文件都保留下来解锁。他们对"可能什么都不做"是什么意思?条件是什么?]

datalad项目编写了函数datalad.support.AnnectRepo.localsync((来实现这一点。该功能的核心是

def localsync(self, remote=None, managed_only=False):
"""Consolidate the local git-annex branch and/or managed branches.
This method calls `git annex sync` to perform purely local operations
that:
1. Update the corresponding branch of any managed branch.
2. Synchronize the local 'git-annex' branch with respect to particular
or all remotes (as currently reflected in the local state of their
remote 'git-annex' branches).
If a repository has git-annex's 'synced/...' branches these will be
updated.  Otherwise, such branches that are created by `git annex sync`
are removed again after the sync is complete.
[...]
"""
[...]
cmd = ['sync']
[...]
cmd.extend([
# disable any external interaction and other magic
'--no-push', '--no-pull', '--no-commit', '--no-resolvemerge',
'--no-content'])
self.call_annex(cmd)
# a sync can establish new config (e.g. annex-uuid for a remote)
self.config.reload()
# cleanup sync'ed branch if we caused it
if not had_synced_branch and synced_branch in self.get_branches():
lgr.debug('Remove previously non-existent %s branch after sync',
synced_branch)
self.call_git(
['branch', '-d', synced_branch],
)

所以需要的命令似乎是git annex sync --no-push --no-pull --no-commit --no-resolvemerge --no-content。这可能会生成特殊的git附件分支,其名称以"开头;已同步/&";,其可能也已经存在于先前的同步操作中。因此,如果它们事先不存在,此函数将删除它们。

最新更新