git config --global user.name 'kimraeyoung'
git config --global user.email '<깃헙 계정 이메일>'
git config --glboal alias.co checkout (checkout 을 co로 변경)
git config --global alias.br branch (branch를 br로 변경)
git config --global alias.ci commit (commit을 ci로 변경)
git config --global alias.st status (status를 st로 변경)
git config --global alias.lg "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
git config --listcd ~
mkdir git-exer
cd git-exer
echo "파일 생성" >> README.md
git init
git add README.md
git commit -m "initial commit"
git remote add origin <원격 저장소>
git push -u origin master
git clone <원격 저장소>

add <파일명> 명령어를 사용했을 때 git의 관리 대상으로 파일을 추적한다.Untracked가 된다.commit이 가능한 상태이다.add 하면 Staged상태가 된다.commit 을 하면 Unmodified가 된다.Stage(add) 상태가 되어야 commit을 할 수 있다.
파일들의 상태를 확인할 수 있다. git이 추적하는 파일과 아닌 파일들을 확인할 수 있다.
git add
git add . 추적되지 않는 모든 파일을 Staged 상태로 변경한다.git add <파일명> 해당 파일만 Staged 상태로 변경한다.git commit
Staged 상태의 파일을 저장한다.Staged 상태가 Unmodified 상태로 변경된다.해시값을 키로 생성한다.git commit -m "메모 .." 메모와 함께 파일을 저장한다.git commit -a add를 같이한다.git commit -am -a와 -m을 합친 것이다.git commit —amend 만약 Stage에 아무것도 없다면git log

git branch
git branch <브랜치 네임>git branch -D <브랜치 네임>git push origin —delete <브랜치 네임>git fetch -pgit branch -r
git checkout <브랜치 네임> or <해시 키 값>
git push
원격 저장소에 저장할 수 있다.
clone 한 리모트 저장소에 쓰기 권한이 있어야 한다.
같은 브랜치로 여러 명이 받아서 작업 후 누군가 push를 했다면 다른 사람은 push가 되지 않는다.

다른 사람이 작한 것 을 가져와서 합친 후 (merge or rebase) 후 push 할 수 있다.
push가 거절당했을 때 로컬 브랜치의 파일들을 원격 저장소에 덮어씌우려고 한다면?
git pull
clone한 서버에서 데이터를 가져와 자동으로 현재 잡헙하는 코드와 merge한다.

충돌이 났을 때 아래와 같이 merge가 되지 않는다.

cat <파일명>으로 변경된 파일을 확인할 수 있다.

이렇게 충돌이 날 경우 변경된 부분을 수정 후 다시 커밋 후 push 해야 한다.
git merge —abort
- 이전에 하려던 git pull이 취소된다.
git fetch
clone 한 서버에서 데이터를 가져오지만 merge하지 않는다.
git log —all 확인하면 아래와 같이 데이터는 가져오지만 merge 되어있지 않다.
stash
git stashgit stash listgit popgit dropmerge
reabase
merge와 같이 코드를 합치지만 rebase 한 브랜치의 커밋이 이전 상태로 생성된다.
git rebase --abort 원래 상태로 되돌아간다.

git rebase -i @~3 ( @는 HEAD 이고 3은 최근 커밋 한 3개를 말한다. ) 최근 3개의 커밋을 하나로 합칠 수 있다.
conflict가 날 경우 충돌이 나는 파일을 변경한 뒤 add 만 한 후 git rebase —continue 를 실행한다.
reset
show 커밋 상태를 보여준다.HEAD === @)git reset --soft <commit hash or @~3>git reset --mixed <commit hash>git reset --hard <commit hash>