기본적으로  commit message는

아래 명령어로 간단하게 만들 수 있다.

$ git commit -m "messages~~~~~~~~~"


하지만 이렇게 간단하게 하는 경우는 드물지.

따라서 commit message template 를 미리 만들어 놓고, 내용을 수정 하여 commit 하면 편하다.


Step 1. commit template 지정

$ git config --global commit.template ~/.gitmessage.txt


Step 2. editor 지정

$ git config --global  core.editor  vim


Step 3. ~/.gitconfig에 제대로 적용되었는지 확인 (세 개 중 아무거나)

$ git config --global -l  or 

$ git config --global --get commit.template 

$ cat ~/.gitconfig)


그리고 commit 할 때, 

$ git commit


하면, vim 이 실행되면서 설정한 ~/.gitmessage.txt 파일이 올라 올 꺼임.


commit message가 저장되면 .git/COMMIT_EDITMSG 파일에 그 내용이 저장되고

git push 를 하면 그 내용을 gerrit 서버로 올린다.


GIT 을 위한 파일들 (included Folder)

(project dir)/.git                 : repository 기본 폴더

(project dir)/.git/config       : git 명령어를 사용되어 지는 git local config 파일

~/.gitconfig : git 명령어를 사용되어 지는 git global config 파일


(project dir)/.git/config

[core]

repositoryformatversion = 0

filemode = true

bare = false

logallrefupdates = true

[remote "origin"]

url = ssh://hakhyun.jee@계정:29411/프로젝트

fetch = +refs/heads/*:refs/remotes/origin/*

[branch "branch name"]

remote = origin

merge = refs/heads/ branch name

[branch "branch name"]

remote = origin

merge = refs/heads/ branch name


.gitconfig

[user]

name = hakhyun.jee

email = hakhyun.jee@계정

[init]

        templatedir = /data001/hakhyun.jee/git_templateDir

#    templatedir = /data001/hakhyun.jee/.git_template

[core]

editor = vi

editer = vim

[merge]

tool = vimdiff

[commit]

template = /data001/hakhyun.jee/git_templateDir/git_commit_template.txt

[color]

ui = auto

[gerrit]

        createChangeId = true


[alias]

    gr = log --graph --full-history --all --color --pretty=tformat:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s%x20%x1b[33m(%an)%x1b[0m"



config 파일 ((project dir)/.git/config ~/,gitconfig) 에 config 내용 추가 / 수정 / 삭제 / LIST / GET

추가 : $ git config --global --add user.name hakhyun.jee

수정 : $ git config --global --replace-all user.name hakhyun.jee

삭제 : $ git config --global --unset user.name hakhyun.jee

LIST :  $ git config --global -l

GET :  $ git config --global --get user.name hakhyun.jee

--local : (project dir)/.git/config 에 추가

--global : ~/.gitconfig에 추가



ref site : https://git-scm.com/docs/git-config

https://m.blog.naver.com/dongsuyeom/100131823020

+ Recent posts