[Git] 기본설정하기 (git config)
[Git] 기본설정하기 (git config)
git을 사용할때 처음에 세팅해주면 유용한 것들 있습니다.
명령어를 축약해서 간단한 명령어로 사용하거나,
아이디/패스워드를 입력하면 특정시간동안 세션(?)을 유지하도록 할 수 있습니다.
제가 사용하는 몇가지 config 값들을 정리했습니다.
git config --list
git config --global credential.helper osxkeychain
git config --global credential.helper 'cache --timeout 7200'
git config --global init.defaultbranch main
git config --global init.templatedir ~/.git-templates
git config --global alias.br branch
git config --global alias.co checkout
git config --global alias.st status
git config --global alias.ci commit
git config --global alias.cia 'commit --amend'
git config --global alias.a 'add -A'
git config --global alias.cob 'checkout -b'
git config --global alias.d diff
git config --global push.default current
git config --global branch.main.remote origin
git config --global branch.main.merge refs/heads/main
git config --global user.name seunggabi
git config --global user.email seunggabi@gmail.com
git config 설정 확인 및 변경하기
git을 사용하는 경우 config 설정에 대한 내용을 볼 필요가 있습니다. 예를들어 사용자 이름이나 email 등을 확인할 수 도 있겠죠
webisfree.com
https://stackoverflow.com/questions/658885/how-do-you-get-git-to-always-pull-from-a-specific-branch
How do you get git to always pull from a specific branch?
I'm not a git master, but I have been working with it for some time now, with several different projects. In each project, I always git clone [repository] and from that point, can always git pull,...
stackoverflow.com
---
mkdir -p ~/.git-templates/hooks
git config --global init.templatedir '~/.git-templates'
vi ~/.git-templates/hooks/prepare-commit-msg
#!/bin/bash
if [[ -z "${SKIP_BRANCH}" ]]; then
SKIP_BRANCH=(master develop release hotfix)
fi
NAME=$(git symbolic-ref --short HEAD)
NAME="${NAME##*/}"
JIRA=`echo ${NAME} | egrep -o '.+-[0-9]+_' | egrep -o '.+-[0-9]+'`
ISSUE=`echo ${NAME} | egrep -o '#[0-9]+_' | egrep -o '#[0-9]+'`
EXCLUDED=$(printf "%s\n" "${SKIP_BRANCH[@]}" | grep -c "^${NAME}$")
PREFIX=""
if [[ -n ${JIRA} ]]; then
PREFIX="[${JIRA}] "
fi
if [[ -n ${ISSUE} ]]; then
PREFIX="${PREFIX}(${ISSUE}) "
fi
PREFIX_ESCAPE=`echo ${PREFIX} | sed -e 's/\[/\\\\[/g' | sed -e 's/\]/\\\\]/g'`
DONE=$(grep -c "${PREFIX_ESCAPE}" $1)
if ! [[ ${EXCLUDED} -eq 1 ]] && ! [[ ${DONE} -ge 1 ]]; then
sed -i.bak -e "1s/^/${PREFIX}/" $1
fi
chmod a+x ~/.git-templates/hooks/prepare-commit-msg
git init
https://gist.github.com/seunggabi/8fa40a3585d37519db5beab5f0563766
prepare-commit-msg
prepare-commit-msg. GitHub Gist: instantly share code, notes, and snippets.
gist.github.com