"Git config"의 두 판 사이의 차이

 
(사용자 4명의 중간 판 16개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
{{소문자}}
;git config
;git config
* 특정저장소 또는 전역 옵션을 조회·설정하는 git 명령어


==실습==
==실습1: 계정 설정==
<source lang='cli'>
* 사용자 이름과 이메일 설정
root@zetawiki:~# mkdir -p workspace/hello
<syntaxhighlight lang='console'>
root@zetawiki:~# cd workspace/hello/
root@zetawiki:~# git config -l
root@zetawiki:~/workspace/hello# git init
root@zetawiki:~# git config --global user.name 'gituser1'
Initialized empty Git repository in /root/workspace/hello/.git/
root@zetawiki:~# git config --global user.email gituser1@zetawiki.com
</source>
root@zetawiki:~# git config -l
<source lang='cli'>
user.name=gituser1
root@zetawiki:~/workspace/hello# echo 'hello world' > greet.txt
user.email=gituser1@zetawiki.com
root@zetawiki:~/workspace/hello# git add greet.txt
</syntaxhighlight>
root@zetawiki:~/workspace/hello# git commit -m 'hello world!'
<syntaxhighlight lang='console'>
[master (root-commit) f4af7c0] hello world!
root@zetawiki:~# cat ~/.gitconfig  
Committer: root <root@zetawiki.example.com>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
 
    git config --global user.name "Your Name"
    git config --global user.email you@example.com
 
After doing this, you may fix the identity used for this commit with:
 
    git commit --amend --reset-author
 
1 file changed, 1 insertion(+)
create mode 100644 greet.txt
</source>
:→ git 사용자의 이름과 이메일이 설정되지 않음
<source lang='cli'>
root@zetawiki:~/workspace/hello# git config --global user.name "gituser1"
root@zetawiki:~/workspace/hello# git config --global user.email gituser1@zetawiki.com
root@zetawiki:~/workspace/hello# cat ~/.gitconfig
[user]
[user]
name = gituser1
name = gituser1
email = gituser1@zetawiki.com
email = gituser1@zetawiki.com
</source>
</syntaxhighlight>
<source lang='cli'>
 
root@zetawiki:~/workspace/hello# echo 'good morning' >> greet.txt
==실습2: alias 설정==
root@zetawiki:~/workspace/hello# git add greet.txt
* "push origin master"를 "po" alias 설정
root@zetawiki:~/workspace/hello# git commit -m 'good morning!'
<syntaxhighlight lang='console'>
[master 7eca13f] good morning!
$ git config --global alias.po "push origin master"
1 file changed, 1 insertion(+)
$ git config -l
</source>
alias.po=push origin master
</syntaxhighlight>
<syntaxhighlight lang='console'>
$ cat ~/.gitconfig
[alias]
po = push origin master
</syntaxhighlight>
<syntaxhighlight lang='console'>
$ git po
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.03 KiB | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@gitlab.com:revinet/www-kumul-pe-kr.git
54acfa0..4e3dc6e  master -> master
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[git commit]]
{{z컬럼3|
*[[git 명령어]]
* [[.gitconfig]]
*[[Your name and email address were configured automatically based]]
* [[git init]]
* [[git commit]]
* [[git 명령어]]
* [[git config --list]]
* [[git config --global --edit]]
* [[Your name and email address were configured automatically based]]
}}
 
==참고==
* https://git-scm.com/book/ko/v2/Git의-기초-Git-Alias


[[분류: git]]
[[분류: git]]

2024년 11월 26일 (화) 16:04 기준 최신판

1 개요[ | ]

git config
  • 특정저장소 또는 전역 옵션을 조회·설정하는 git 명령어

2 실습1: 계정 설정[ | ]

  • 사용자 이름과 이메일 설정
root@zetawiki:~# git config -l
root@zetawiki:~# git config --global user.name 'gituser1'
root@zetawiki:~# git config --global user.email gituser1@zetawiki.com
root@zetawiki:~# git config -l
user.name=gituser1
user.email=gituser1@zetawiki.com
root@zetawiki:~# cat ~/.gitconfig 
[user]
	name = gituser1
	email = gituser1@zetawiki.com

3 실습2: alias 설정[ | ]

  • "push origin master"를 "po" alias 설정
$ git config --global alias.po "push origin master"
$ git config -l
alias.po=push origin master
$ cat ~/.gitconfig
[alias]
	po = push origin master
$ git po
	Counting objects: 4, done.
	Delta compression using up to 4 threads.
	Compressing objects: 100% (3/3), done.
	Writing objects: 100% (3/3), 1.03 KiB | 0 bytes/s, done.
	Total 3 (delta 0), reused 0 (delta 0)
	To git@gitlab.com:revinet/www-kumul-pe-kr.git
		54acfa0..4e3dc6e  master -> master

4 같이 보기[ | ]

5 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}