티스토리 뷰

728x90

github 주요 명령어 정리

 

git init
git add .
git commit
git log
git status
git restore --staged README.md
git status
git remote add https://~
git remote -v
git branch -m master main
git push -u origin main

 

git push --set-upstream origin main
로컬저장소에 있는 브랜치와 원격저장소에 있는 브랜치를 연결하는 명령어

git fetch
git pull

git branch --set-upstream-to=origin/main main
git pull
git push

git checkout -b feature/#1
git push origin feature/#1
git branch --set-upstream-to=origin/feature/#1 feature/#1
git push

 

Fast-forward
- 현재 브랜치; feature/#1
1. git checkout main
2. git merge feature/#1
3. git add .
4. git commit
5. git push origin main


merge commit
- 현재 브랜치; feature/#2
1. git merge main
2. 충돌이 발생했을 경우, 문제를 해결하고 그렇지 않다면 skip
3. git add .
4. git commit
5. git push
6. git checkout main
7. git merge feature/#2
8. git push origin main


rebase
1. git rebase feature/#1 (베이스로 지정할 브랜치명)
2. 만약 충돌이 발생하면 로그가 발생하고 그렇지 않은 경우는 바로 Rebase가 된다.
3. 만약 충돌이 발생했다면, Conflict 발생한 소스 코드를 수정 후, commit
git add .
git commit -m "FIX: conflict HealthController"
4. 중지된 Rebase를 계속 진행; git rebase --continue
5. 최종결과; 깔끔한 커밋 히스토리 유지

 

 

- 현재 브랜치; feature/#1
- feature/#1 -> feature/#2 -> main으로 merge하기

git stash
git pull
git checkout feature/#2
git merge feature/#1
git add .
git commit -m "MERGE: conflict"
git checkout main
git merge feature/#2
728x90
250x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/06   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함