2018-07-13 15:13
浏览 63


I have an utility in Go that runs commits checkouts via os/exec and then does some operations on files from the commit.

I suspect that at the moment this command returns its return code:

_, err := exec.Command("git", "-C", sourceDir, "checkout", hash).Output()

The whole file tree is up to date in the folder and I can do whatever I want with the files, without the need to wait for some operations to finish in background.

What if it's a very large repository, where one commit differs much from another one and it takes time to sync deleted/added/modified files when switching from one commit to another?

Can I run my operations right after git checkout returns 0?

图片转代码服务由CSDN问答提供 功能建议

我在Go中有一个实用程序,可通过 os / exec 运行提交检出,然后执行


  _,err:  = exec.Command(“ git”,“ -C”,sourceDir,“ checkout”,哈希)。Output()

整个文件树 日期在文件夹中,我可以对文件进行任何操作,而无需等待后台完成某些操作。

如果它是一个非常大的存储库,其中有一个提交,该怎么办 从另一个提交切换到另一个提交有很大的不同,并且从一个提交切换到另一个提交需要花费时间来同步已删除/添加/修改的文件?

我可以在 git checkout之后立即运行我的操作吗? code>返回 0

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douying1119 2018-07-13 16:03

    git checkout does not exit until the checkout is completed (or has failed).

    Comments about auto-gc in the background are not particularly relevant here, since auto-gc is not related to whether the checkout has finished. For that matter, git checkout does not run git gc --auto: there is no point since git checkout does not create new Git objects. A reasonably current list of things that do invoke git gc --auto (as of about 2.18) is:

    • git am
    • git commit
    • git fetch
    • git merge
    • git receive-pack (servers)
    • git rebase
    解决 无用
    打赏 举报

相关推荐 更多相似问题