Last active
May 26, 2021 00:06
-
-
Save ozv-s-urabe/a178e4094af844e35eec43e3a1162d84 to your computer and use it in GitHub Desktop.
hapitas-reset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
if [ -f $HOME/.gitconfig ] | |
then | |
rm -fv $HOME/.gitconfig || : | |
fi | |
if [ $(ls $HOME/.ssh/|grep ^id_|wc -l) -ne 0 ] | |
then | |
for file in $(ls $HOME/.ssh|grep id_); do rm -fv $HOME/.ssh/$file; done | |
fi | |
if [ -d $HOME/.aws ] | |
then | |
rm -rfv $HOME/.aws || : | |
fi | |
read -p "github のユーザ名を入力してください (ex. Shinichi Urabe): " USER | |
git config --global user.name $USER | |
read -p "github の email を入力してください (ex. [email protected]): " EMAIL | |
git config --global user.email $EMAIL | |
echo | |
ssh-keygen -t ed25519 -q -f $HOME/.ssh/id_ed25519 -N '' | |
echo 以下の公開鍵を https://github.com/settings/ssh/new に登録してください | |
echo | |
cat $HOME/.ssh/id_ed25519.pub | |
echo | |
read -p "上記キーを github に登録できたら Enter キーを押してください: " EMPTY | |
echo 別途共有されている AWS KEY, AWS Secret KEY を手元に用意してください | |
read -p "aws の Access key ID を入力してください (ex. AKIAAAAAAAAAAAAAAAAAAAAAAAAAA): " AWS_ACCESS_KEY_ID | |
read -p "aws の secret key を入力してください (ex. *****************):): " AWS_SECRET_ACCESS_KEY | |
aws configure set aws_access_key_id ${AWS_ACCESS_KEY_ID} | |
aws configure set aws_secret_access_key ${AWS_SECRET_ACCESS_KEY} | |
aws configure set region ap-northeast-1 | |
for dir in $(find ~/Hapitas -name .git -type d) | |
do | |
cd $dir/.. | |
git fetch | |
MAIN=master | |
if [ $(git branch -r|grep origin/master |wc -l) -eq 0 ] | |
then | |
MAIN=main | |
fi | |
echo reseting $(basename $(pwd))... | |
git clean -df | |
git stash | |
git checkout -b dummy-branch-$(date +%Y%m%d%H%M%S) | |
git branch -D $MAIN || : | |
git checkout -b $MAIN origin/$MAIN | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment