简体   繁体   English

如何从 git 附件调整分支提交

[英]How do I commit from a git annex adjusted branch

I have a git and git annex project on a filesystem that does not suppport symlinks.我在不支持符号链接的文件系统上有一个gitgit annex项目。 Thus, I have to work with an adjusted branch, that means that on top of my "normal" branch I execute git annex adjust --unlock so that I get a new branch on which my annex'ed files are not symlinks into the annex store, but the original files.因此,我必须使用调整后的分支,这意味着在我的“正常”分支之上,我执行git annex adjust --unlock以便我得到一个新分支,在该分支上我的附件文件不是符号链接到附件存储,但原始文件。 My commit tree looks then like this:我的提交树看起来像这样:

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

When I commit now, I would do so on the adjusted branch I guess, because git-annex cannot create the symlinks, using git annex add MYFILE and git commit`:当我现在提交时,我想我会在调整后的分支上这样做,因为 git-annex 无法创建符号链接,使用git annex add MYFILE和 git 提交`:

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

What I want is a commit to the master branch that is in the standard git-annex format, meaning that annex'ed files are symlinks to their place in the annex store.我想要的是对标准 git-annex 格式的 master 分支的提交,这意味着附件文件是指向它们在附件存储中的位置的符号链接。 Finally, because I cannot have symlinks checked out at my file system, I need to automatically create a new adjusted branch that replaces the symlinks in the commit by the actual files.最后,因为我不能在我的文件系统中签出符号链接,我需要自动创建一个新的调整分支,用实际文件替换提交中的符号链接。

So how do I get from the situation above to the following:那么我如何从上述情况得到以下情况:

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

The git annex manual on git annex adjust only tells me how to get an adjusted branch, but not how to reverse the adjusting. git 附件调整上的 git 附件手册仅告诉我如何获得调整后的分支,而不告诉我如何反转调整。 The adjusting concept page is a bit cryptical for me (highlighted text mine). 调整概念页面对我来说有点神秘(突出显示的文本)。

A user's commits on the adjusted branch have to be reverse adjusted to get changes to apply to the master branch.用户在调整后的分支上的提交必须进行反向调整才能将更改应用于主分支。

This reversal of one adjustment can be done as just another adjustment.这种调整的逆转可以作为另一种调整来完成。 Since only files touched by the commit will be reverse adjusted, it doesn't need to reverse all changes made by the original adjustment.由于只有被提交触及的文件会被反向调整,所以不需要反向所有由原始调整所做的更改。 [ how shall I reverse adjust from files to symlinks when my filesystem doesn't support them? [当我的文件系统不支持它们时,我应该如何从文件反向调整到符号链接? ] ]

For example, reversing the unlock adjustment might lock the file.例如,反转解锁调整可能会锁定文件。 Or, it might do nothing, which would make all committed files remain unlocked.或者,它可能什么都不做,这会使所有提交的文件保持解锁状态。 [ what do they mean with "might do nothing"? [ “可能什么都不做”是什么意思? What are the conditions?条件是什么? ] ]

The datalad project have written the function datalad.support.AnnexRepo.localsync() to accomplish this. datalad 项目编写了 function datalad.support.AnnexRepo.localsync()来完成此操作。 The core of that function is function的核心是

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 (eg 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], )

so the command needed seems to be git annex sync --no-push --no-pull --no-commit --no-resolvemerge --no-content .所以所需的命令似乎是git annex sync --no-push --no-pull --no-commit --no-resolvemerge --no-content This might generate special git annex branches whose names start with "synced/...", which might also already be there from a previous sync operation.这可能会生成特殊的 git 附件分支,其名称以“synced/...”开头,这也可能在之前的同步操作中已经存在。 So this function deletes them if they were not already present beforehand.因此,如果它们事先不存在,则此 function 将删除它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM