2024年4月

git log --all -- ${dirname}

# choose the COMMIT_TAG that removed the folder 

git checkout ${COMMIT_TAG}^ ${pathtodir}${dirname}

# 重置当前分支的 HEAD 指针到指定的提交
git reset ${COMMIT_TAG} -- ${pathtodir}${dirname}


git revert  -n ${COMMIT_TAG}
git commit -m "revert this commit"

Sometimes, we need to run a script to modify saveral files at once.

We can use xargs on shell tube.

ls | xargs echo 

As the command before, xargs run echo and use the result from ls.

this example shows how to use xargs modify all index.html that change *.js to *.js?ver=xxx

verStr="1.0.0"

# set version for  .css .js files
find -name "index.html" | xargs -i cp {} {}.bak 

find -name "index.html" | xargs sed -i 's@\.js.*\"@.js?ver='${verStr}'\"@g'

# reset files
# find -name "index.html" | xargs -i mv {}.bak {}