duanqin7791 2018-07-13 15:13
浏览 63
已采纳

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?

  • 写回答

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
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Stata链式中介效应代码修改
  • ¥15 latex投稿显示click download
  • ¥15 请问读取环境变量文件失败是什么原因?
  • ¥15 在若依框架下实现人脸识别
  • ¥15 网络科学导论,网络控制
  • ¥100 安卓tv程序连接SQLSERVER2008问题
  • ¥15 利用Sentinel-2和Landsat8做一个水库的长时序NDVI的对比,为什么Snetinel-2计算的结果最小值特别小,而Lansat8就很平均
  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错