git init
해당 폴더 git이 감시 시작
repository 생성
git branch -M main
브랜치의 이름을 변경
-M 옵션은 브랜치 이동을 강제로 수행
원격
로컬
git add .
스테이징 하기
git commit -m "first commit"
repository로 이동
git remote add origin git@github.com:<깃허브 아이디>/<원격 저장소 이름>.git
origin이라는 이름으로 GitHub의 <깃허브 아이디>/<원격 저장소 이름>.git 원격 저장소를 추가하는 역할
이후 origin이라는 원격 저장소의 별칭(alias)으로 원격 저장소를 참조하여 작업 가능
git remote add origin : Git에서 원격 저장소를 추가하는 명령어
git@github.com:<깃허브 아이디>/<원격 저장소 이름>.git: 추가할 원격 저장소의 주소
git push -u origin main
git push -u <원격저장소 주소> <로컬 브랜치 이름>
-u 는 upstream 약자
git branch 가지1 : 가지치기
git switch 가지1 : 친 가지로 이동
git branch -d 브랜치명 : 이미 merge된 브랜치 제거
git branch -D 브랜치명 : 아직 merge 안된 브랜치 제거
- 3way merge
: 수정 코드가 곂치지 않으면 정상 merge
: 수정 코드가 곂치면 conflict 발생
- fast-forward merge
- rebase & merge
- squash & merge
git status : 상태 조회
git log -3
git log --oneline --all
git log --oneline --all --graph
git diff
git difftool
git remote -v : 현재 깃 저장소가 뭔지 보여주기
C:\>git rm --cached -r .idea
C:\>git commit -m "잘못 올린 폴더 삭제"
C:\>git push
private repo를 사용할 때 문제 발생
에러
err: fatal: could not read Username for 'https://github.com': No such device or address
해결책
git remote set-url origin https://{access_key:developers에서 발급받은 것}@github.com/JeongJaeyoung/iintheworld.git
git reset --hard HEAD
git pull
https://stackoverflow.com/questions/1125968/how-do-i-force-git-pull-to-overwrite-local-files
커밋 합치기
#git rebase -i [수정을 시작할 커밋의 이전 커밋]
git rebase -i HEAD~3
코딩애플 : 매우쉽게 알려주는 git & github
https://batory.tistory.com/479