それ以上のmasterブランチを使用し始める場合、現在のブランチを自動的にプッシュしたいかもしれません。私のフック( .git/hooks/post-commit
)は次のようになります:
#!/usr/bin/env bash
branch_name=`git symbolic-ref --short HEAD`
retcode=$?
non_push_suffix="_local"
# Only push if branch_name was found (my be empty if in detached head state)
if [ $retcode = 0 ] ; then
#Only push if branch_name does not end with the non-push suffix
if [[ $branch_name != *$non_push_suffix ]] ; then
echo
echo "**** Pushing current branch $branch_name to origin [i4h_mobiles post-commit hook]"
echo
git push origin $branch_name;
fi
fi
git symbolic-refでブランチ名を判断できる場合は、現在のブランチをプッシュします。
" Gitで現在のブランチ名を取得する方法これと他の方法で現在のブランチ名を取得します。
あるブランチの自動プッシュは、いくつかのソーセージ作成起こる(あなたが押した後に簡単に転倒することはできない)。したがって、フックは定義された接尾辞で終わるブランチをプッシュしません(この例では "_local")。