duanqin7791
duanqin7791
2018-07-13 15:13
浏览 54

git在什么时候完成执行操作?

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
    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
    点赞 评论

相关推荐