제대로 파는 Git & GitHub - by 얄코 3-2 ~ 4-4까지
주가 될 브랜치에서 git merger를 실행
git merge 브랜치명
:wq으로 자동입력된 커밋 메시지 저장하여 마무리💡 merge는 reset으로 되돌리기 가능
merge도 하나의 커밋merge하기 전 해당 브랜치의 마지막 시점으로병합된 브랜치는 삭제
git branch -d 브랜치명
합쳐질 브랜치로 이동 후 실행
merger와는 반대git rebase 브랜치명
git merge 합쳐질_브랜치명
병합된 브랜치는 삭제
git branch -d 브랜치명
git status확인
당장 충돌 해결이 어려울 경우 아래 명령어로 merge 중단
git merge --abort
해결 가능 시 충돌 부분을 수정한 뒤 git add ., git commit으로 병합 완료
git status 확인rebase 중단git rebase --abort
해결 가능 시
git add .git rebase --continue
merge

rebase

브랜치 삭제

💡 rebase는 충돌 가능시 CLI로 진행 권장
- 로그인하기
- personal access token 만들기
- 우측 상단의 프로필 -
Settings
Developer Settings
Personal access tokens-Generate new token
repo및 원하는 기능에 체크, 기간 설정 뒤Generate token
Note: 토크 명칭
Expiration: 만료기간(7일, 30일, 60일, 90일, 만료기간 없음)
repo:
- 토큰 안전한 곳에 보관해 둘 것




위의 Github는 자동으로 생성된 것
아래의 Github는 이번에 새로 만든 것


Public: 모두에게 보일 수 있는 프로젝트Private: 허용된 인원만 볼 수 있는 프로젝트


Manage Access가 Collaborators로 바뀌었습니다.Add people⭐️ HTTPS 프로토콜 사용
첫 생성 시 모습

GitHub 레포지토리 생성 후 복붙 명령어
git remote add origin (원격 저장소 주소)
로컬의 Git 저장소에 원격 저장소로의 연결 추가
origin 사용. 다른 것으로 수정 가능git branch -M main
main으로git push -u origin main
로컬 저장소의 커밋 내역들 원격으로 push(업로드)
-u 또는 --set-upstream : 현재 브랜치와 명시된 원격 브랜치 기본 연결결과
git remote add origin https://github.com/subscriptioncat/git-practice.git
git branch -M main
git push -u origin main
⭐️ GitHub의 해당 레포지토리 페이지 새로고침하여 살펴보기
원격 목록 보기
git remote
git remote -v원격 지우기 (로컬 프로젝트와의 연결만 없애는 것. GitHub의 레포지토리는 지워지지 않음)
git remote remove (origin 등 원격 이름)

Download ZIP: 파일들만 다운받음, Git 관리내역 제외(.git이 없음)


hj247@DESKTOP-R1VCF2H MINGW64 /f/project_download
$ git clone https://github.com/subscriptioncat/git-practice.git
Cloning into 'git-practice'...
remote: Enumerating objects: 83, done.
remote: Counting objects: 100% (83/83), done.
remote: Compressing objects: 100% (48/48), done.
remote: Total 83 (delta 34), reused 83 (delta 34), pack-reused 0
Receiving objects: 100% (83/83), 7.62 KiB | 1.52 MiB/s, done.
Resolving deltas: 100% (34/34), done.터미널이나 Git Bash에서 대상 폴더 이동 후
git clone (원격 저장소 주소)
git push
git push -u origin main으로 대상 원격 브랜치가 지정되었기 때문에 가능git pull
push 해보기
$ git push
To https://github.com/subscriptioncat/git-practice.git
! [rejected] main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/subscriptioncat/git-practice.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
push 할 것이 있을 시 pull 하는 두 가지 방법
git pull --no-rebase- merge 방식
- 소스트리에서 확인해보기
git pull --no-rebase Auto-merging leopards.yaml Merge made by the 'ort' strategy. leopards.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)git pull --rebase- rebase 방식
- pull 상의 rebase는 다름 (협업시 사용 OK)
$ git pull --rebase Successfully rebased and updated refs/heads/main.
push하기
pull 하여 충돌상황 마주하기
--no-rebase와 --rebase 모두 해 볼 것git push --force