看板 Linux 關於我們 聯絡資訊
各位好,本人想用一個簡單的shell script 來讓某目錄下的多個submodule,並在其中執行git checkout (commit SHA) 及 git restore . 目前想到的大概是這樣,才後會用多個if來找我要的submodule: for item in /path/to/submodule/*;do if [${item} == 'name'];then git restore . git checkout (commit SHA) fi done 然而 if[${item} == 'name'] 這不要怎麼寫才對 我希望name對應到的是路徑最右邊的item 先謝謝各位看完問題了,因為很少寫shell所不太會問,不清楚的地方我會再補充 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 47.187.207.248 (美國) ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1674808259.A.221.html ※ 編輯: VivianAnn (47.187.207.248 美國), 01/27/2023 16:34:14
abc0922001: 不是下 git submodule update 嗎? 01/27 18:10
lantw44: if [ "${item}" = name ] 所有的空格都不能省略。 01/27 18:31
lantw44: 不過應該不用自己寫 for,可以用 git submodule foreach 01/27 18:32
drm343: 這個我第一個想到的也是 git submodule foreach 01/27 20:47
VivianAnn: 會問這個是因為submodule很多,而且每個submodule都會 01/28 16:27
VivianAnn: 用一個特定的commit,這可能只能用git checkout來做。 01/28 16:27
VivianAnn: 有時候因為不明原因,某幾個submodule的commit會跑掉, 01/28 16:27
VivianAnn: 要再手動一個個調回很費時 01/28 16:27
lantw44: 你可以把 if 那段寫在給 foreach 執行的 script 裡。 01/28 19:57
okgogogo: 怎不用repo 02/07 16:58
simpson083: http://i.imgur.com/cslN04M.jpg 02/14 08:38