Note/Git&Github

github 명령어

yeonahn 2025. 3. 15. 02:43

원래 사용하던 블로그 - https://yeonnan.hashnode.dev/github-1?source=more_series_bottom_blogs

 

github 명령어

초기 세팅 git clone 하기 전 .git 파일 만들기 git init git add, git commit, git push 브랜치 활용하기 현재 브랜치 위치 git branch 브랜치 생성 git branch 브랜치명 브랜치 이동 git switch 브랜치명 or git checkout 브

yeonnan.hashnode.dev

 

 

초기 세팅

git clone 하기 전 .git 파일 만들기 git init

git add, git commit, git push


브랜치 활용하기

  • 현재 브랜치 위치 git branch
  • 브랜치 생성 git branch 브랜치명
  • 브랜치 이동 git switch 브랜치명 or git checkout 브랜치명
  • 브랜치 한번에 생성 & 이동 git switch -c 브랜치명 or git checkout -b 브랜치명
  • 브랜치 합치기 -> git switch 최종브랜치로 이동한 다음 git merge로 합치기
    • git switch 최종브랜치이름  ex. main
    • git merge 합칠브랜치이름  ex. login

깃허브에서는 브랜치가 보이지만 로컬에서는 안보일 때 git branch -r

git branch -r 로 하면 깃허브에 있는 브랜치가 보이는데 이때 git checkout -t origin/dev


깃허브 브랜치 이름 변경

oldname이라는 이름의 브랜치를 newname으로 바꾸기

1. 로컬에서 브랜치 이름 변경 git branch -m oldname newname⁠

2. 원격 저장소에 반영 git push origin :oldname

3. 새로만들어진 newname 브랜치 push git push --set-upstream origin newname