Git

並行執行兩個 git 命令

  • February 18, 2018

如果兩個git pull命令在同一個目錄中同時執行會發生什麼?

git執行文件鎖定以防止損壞儲存庫。您可能會收到類似的消息

error: cannot lock ref 'refs/remotes/origin/develop': is at 2cfbc5fed0c5d461740708db3f0e21e5a81b87f9 but expected 36c438af7c374e5d131240f9817dabb27d2e0a2c
From github.com:myrepository
! 36c438a..2cfbc5f  develop    -> origin/develop  (unable to update local ref)
error: cannot lock ref 'refs/remotes/origin/master': is at b9a3f6cf9dafc30df38542e5e51ae4842c50814d but expected 5e6174b3c7071c840effeda6c708d6aef36f7c6a
! 5e6174b..b9a3f6c  master     -> origin/master  (unable to update local ref)

來自git未能獲得鎖的程序。就這些。

如果兩個git pull程序稍微不同步,效果和執行兩次命令是一樣的。

引用自:https://unix.stackexchange.com/questions/424927