매일 github pull push 과정이 헷갈리는 나를 위한 백업,,
Github Repository 생성하기
- github 사이트에서 new버튼으로 새로운 repository를 생성한다.
- git init
- git add .
- git commit -m "commit message"
- git remote add origin github주소 - github의 주소로 remote하기
- git push -u origin master
branch 사용 기본 push
- git clone [url]
- git branch [branchname]
- git checkout [branchname]
- 작업
- git add .
- git commit -m "commit message"
- git push origin [branchname]
- pull request 작성
Git remote url 수정
- 기존 repository 주소 확인 : git remote -v
- 기존 repository 연결 해제 : git remote remove origin
- 새로운 repository 연결 : git remote add origin [새로운 Repository URL]
Git과 연결된 로컬 저장소 변경
.git 폴더를 이동시키면 된다
![](https://velog.velcdn.com/images/haeun-i/post/7a64a558-48e5-46b5-8080-5e99b7b3f661/image.png)
사진 출처 : https://sedangdang.tistory.com/147
Git 브랜치 생성/삭제
브랜치 생성 : git branch [branchname]
브랜치 삭제 : git branch -d [branchname]
Git 한번 pr 후 새로 시작할 때 과정
- 메인 branch 이동 후 master 내용 pull
git checkout main
git pull origin master
- 작업한 브랜치로 이동 후 master를 해당 브랜치에 merge
git merge master