깃, 깃허브 제대로 배우기 (기본 마스터편)

인생노잼시기·2021년 4월 29일
0

🤯GIT

목록 보기
3/5

https://www.youtube.com/watch?v=Z9dvM7qgN9s 보고 따라하기

시작 전에
iTerm2와 oh-my-zsh로 맥 터미널을 꾸밀 수 있다

iTerms2 설치
https://iterm2.com/

oh-my-zsh 설치
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Looking for an existing zsh config...
Found ~/.zshrc. Backing up to /Users/myeongsim/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc.

어떤 브랜치에 있는지도 알 수 있어
설치하는것을 추천한다

git config 세 가지 설정파일

    1. /etc/gitconfig 파일: 시스템의 모든 사용자와 모든 저장소에 적용되는 설정이다.
      git config --system 옵션으로 이 파일을 읽고 쓸 수 있다.
    1. ~/.gitconfig, ~/.config/git/config 파일: 특정 사용자에게만 적용되는 설정이다.
      git config --global 옵션으로 이 파일을 읽고 쓸 수 있다.
    1. .git/config : 이 파일은 Git 디렉토리에 있고 특정 저장소(혹은 현재 작업 중인 프로젝트)에만 적용된다.
      각 설정은 역순으로 우선시 된다. 그래서 .git/config 가 /etc/gitconfig 보다 우선한다.

깃 기본 설정하기

git --version
git version 2.24.3 (Apple Git-128)

git config --list
credential.helper=osxkeychain
user.name=임명심
user.email=msi753@naver.com
core.excludesfile=/Users/myeongsim/.gitignore_global
difftool.sourcetree.cmd=opendiff "LOCAL""LOCAL" "REMOTE"
difftool.sourcetree.path=
mergetool.sourcetree.cmd=/Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh "LOCAL""LOCAL" "REMOTE" -ancestor "BASE"merge"BASE" -merge "MERGED"
mergetool.sourcetree.trustexitcode=true

git config --global -e
-e은 편집을 의미함

vsc를 열고 쉘과 연동시키기
command shift p

code .
git config --global core.editor "code"
git config --global -e
입력하면 vsc가 나온다

git config --global core.editor "code --wait"
git config --global -e
[core]
excludesfile = /Users/myeongsim/.gitignore_global
editor = code --wait

editor가 code였다가 code --wait로 바뀌었다
vsc가 닫히기 전까지 쉘을 사용할 수 없다

git config --global user.name "Ellie"
git config --global user.email "dream@gmail.com"
git config user.name
Ellie

git config --global core.autocrlf input
윈도우는 \r\n으로 저장되는데 깃에 저장할 땐 \n만 남도록 저장해주는 것이다.(true)
맥은 \n으로 저장되는데 메일을 받은 파일에서 \r\n이 남아있을 수 있어 \n만 남도록 설정해줬다.(input)
\r(carriage-return)
\n(line feed)
깃에는 \n만 남는다

.gitconfig파일 내용 변경
[core]
excludesfile = /Users/myeongsim/.gitignore_global
editor = code --wait
autocrlf = input

현재까지 요약

git config --global user.name "Ellie"
git config --global user.email "dream@gmail.com"
git config --global core.autocrlf input

로컬에 깃 저장소 생성하기

mkdir git
cd git
git init 깃 시작하기
open .git 깃 시작하면서 만들어지는 파일 열어보기

rm -rf .git 깃 삭제


git add

스테이징하기
(스테이징은 cached와 동일한 뜻으로 사용되고 있다)
커밋하기 전에 파일의 변화를 감지하는 것
중간중간 git status 확인해보기
git status -h 다양한 옵션 확인가능
git status -s 짧은 버전으로 확인가능

echo Hello world! > a.txt 텍스트파일에 저장하기
echo hello world! > b.txt
echo hello world! > c.txt
git add a.txt 스테이징(tracked된다는 말)
git add .
echo ellie >> a.txt ellie텍스트 추가해서 저장
git rm --cached 언스테이징(track이 해제됨)
echo log > log.log
echo
.log > .gitignore 깃에 제외하고 올리기

git diff

working directory에서 변경된 내용을 확인할 수 있다

만약 스테이징된 변화를 알고 싶으면 옵션을 주면된다
git diff --staged
git diff --cached

git config --global -e
//.gitconfig파일

[difftool "sourcetree"]
	cmd = opendiff \"$LOCAL\" \"$REMOTE\"
	path = 
[mergetool "sourcetree"]
	cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
	trustExitCode = true

git commit

git log

git commit -am "second commit"
a: all
m: message

커밋의 규모는?

기능별로 히스토리에 저장하는 것이 좋다
현재시제를 사용한다
ex) Initialize project
ex) Add LoginService module
ex) Add UserRepository module
ex) Add Welcome page
ex) Add About page
ex) Add light theme

주의사항!
Fix crashing on login module
오류를 수정했다면 그것만 고쳐서 반영한다

UI툴 사용하기

소스트리를 사용하면
한 줄만 커밋할 수도 있다!

profile
인생노잼

0개의 댓글