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 关于#stm32#的问题:寻找一块开发版,作为智能化割草机的控制模块和树莓派主板相连,要求:最低可控制 3 个电机(两个驱动电机,1 个割草电机),其次可以与树莓派主板相连电机照片如下:
  • ¥15 Mac(标签-IDE|关键词-File) idea
  • ¥15 潜在扩散模型的Unet特征提取
  • ¥15 iscsi服务无法访问,如何解决?
  • ¥15 感应式传感器制作的感应式讯响器
  • ¥15 如何使用SC92F8003固件库解析私有协议数据?
  • ¥15 如何在音频中嵌入字符串(水印)信息进行传递
  • ¥30 plc怎么以设计说明书申请软著
  • ¥15 硬盘识别不了,需要初始化,可我的数据怎么办
  • ¥15 lvm2被mask了,怎么unmask都没用(标签-ubuntu|关键词-apt)