Я пришел из подрывной деятельности, и недавно моя компания переключилась на git.Раньше у меня на ноутбуке была запись cron для еженедельного обновления множества проверок.Таким образом, я буду работать с текущими версиями различных компонентов нашей системы;особенно части, которые я не активно развивал, но имел зависимости.Я хотел бы добиться того же с помощью git.
Вот мой старый процесс обновления с помощью svn:
#!/bin/bash -e
checkout="$1"
svn update --accept postpone ${checkout}
# Run a script to report conflicts that I would resolve in the morning.
Я прочитал много постов в блогах на эту тему и задавал вопросы:и я не нашел много последовательных ответов.Кроме того, ни одно из решений, которые я видел до сих пор, не является настолько полным, насколько я ищу.Я учел все эти мнения и создал приведенный ниже сценарий.
Как мне поступить с подмодулями?
Есть ситуации или у меня есть ошибки?не учитывается?
#!/bin/bash -e
checkout="$1"
now=$(date +%Y%m%dT%H%M%S)
cd ${checkout}
# If you are in the middle of a rebase, merge, bisect, or cherry pick, then don't update.
if [ -e .git/rebase-merge ]; then continue; fi
if [ -e .git/MERGE_HEAD ]; then continue; fi
if [ -e .git/BISECT_LOG ]; then continue; fi
if [ -e .git/CHERRY_PICK_HEAD ]; then continue; fi
# Determine what branch the project is on, if any.
ref=$(git branch | grep '^*' | sed 's/^* //')
if [[ $ref = "(no branch)" ]]; then
# The directory is in a headless state.
ref=$(git rev-parse HEAD)
fi
# If there are any uncommitted changes, stash them.
stashed=false
if [[ $(git status --ignore-submodules --porcelain | grep -v '^??') != "" ]]; then
stashed=true
git stash save "auto-${now}"
fi
# If there are any untracked files, add and stash them.
untracked=false
if [[ $(git status --ignore-submodules --porcelain) != "" ]]; then
untracked=true
git add .
git stash save "auto-untracked-${now}"
fi
# If status is non-empty, at this point, something is very wrong, fail.
if [[ $(git status --ignore-submodules --porcelain) != "" ]]; then continue; fi
# If not on master, checkout master.
if [[ $ref != "master" ]]; then
git checkout master
fi
# Rebase upstream changes.
git pull --rebase
# Restore branch, if necessary.
if [[ $ref != "master" ]]; then
git checkout ${ref}
fi
# Restore untracked files, unless there is a conflict.
if $untracked; then
stash_name=$(git stash list | grep ": auto-untracked-${now}\$" | sed "s/^\([^:]*\):.*$/\\1/")
git stash pop ${stash_name}
git reset HEAD .
fi
# Restore uncommitted changes, unless there is a conflict.
if $stashed; then
stash_name=$(git stash list | grep ": auto-${now}\$" | sed "s/^\([^:]*\):.*$/\\1/")
git stash pop ${stash_name}
fi
# Update submodules.
git submodule init
git submodule update --recursive
Спасибо.