У меня есть сценарий, который я создал, который создает хранилище локально, создает первый коммит и создает удаленное репо. Вот он:
#!/bin/bash
function create-repo {
inside_git_repo="$(git rev-parse --is-inside-work-tree 2>/dev/null)"
# check if we already inside a repository
if [ "$inside_git_repo" = true ]; then
echo "Error: It is not possible to create a repository inside another one"
else
#check if the name of repository is not null
if [ "$1" = "" ]; then
echo "Error: Missing one argument (Repository name)"
else
#creating repository folder
echo "Repo will be created with the following name: $1 "
mkdir "$1"
cd "$1" || exit 1
echo
#Create a README.md file to push to remote
echo "# $1" >> README.md
echo
#initializing repo
git init
echo
#staging and commiting README.md file
git add README.md
git commit -m "first commit"
echo
#username in github
username="alanwilliam"
#secret token of github API
token="PUT HERE YOU SECRET TOKEN"
#json that will be sent to github API
json="{ \"name\":\"$1\" }"
#Curl command that does the magic to create the remote on github
curl --user "$username":"$token" --request POST -H "Content-Type: application/json" -d "$json" https://api.github.com/user/repos
echo
echo
echo
#adding remote and pushing
git remote add origin https://github.com/alanwilliam/"$1".git
git push -u origin master
fi
fi
}
Этот код работает просто отлично - он идеально подходит для меня. Я положил его в файл с именем .custom_aliases
, и это сработало. Однако, чтобы git обнаружил этот файл и сделал команду доступной, каждый раз, когда я открываю git bash, мне нужно набрать source ~/.custom_aliases
, чтобы иметь возможность использовать команду в скрипте, что раздражает.
Есть ли способ сделать его всегда доступным, поэтому мне не нужно вводить команду источника каждый раз, когда я открываю git bash?