2022-03-11 @이영훈
git과 더 나아가 git flow를 잘 사용하여 개발 프로젝트 관리를 더 잘 하고 더 적게 일을 하고 더 많은 것을 얻어가면 좋겠습니다
git을 잘 사용하셔서 개발 프로젝트 관리를 더 잘 하고 더 적게 일을 하고 더 많은 것을 얻어가시면 좋겠습니다
일반적인 git command
1.
git add: stage에 추가하는 명령어
git add . // 현재 경로를 포함하여 모든 sub-directory
git add facny.service.ts
Bash
복사
2.
git reset: stage에서 빼는 명령어 (unstage)
3.
git rm: 로컬과 remote 모두에서 파일을 삭제하는 명령어
a.
당연히 push해야 remote에서도 제거가 됩니다
b.
로컬 파일은 유지하고 싶으면 git rm --cache
git rm --cached .DS_Store
Bash
복사
4.
git rebase : 갈라져 나온 조상 브랜치의 최신 것으로 만들고 브랜치를 합칩니다
(@origin/feature) git rebase develop # 'feature' 브랜치를 -> 'develop' 브랜치로 합치기
Bash
복사
5.
git commit : 내용을 커밋합니다.
6.
git push : 커밋 내역을 원격 저장소(remote repository)에 저장합니다.
7.
git checkout : 브랜치를 변경하거나 워킹 트리 파일을 복원합니다. (git switch + git restore)
8.
git switch : 브랜치를 변경합니다.
9.
git restore : 워킹 트리의 파일을 복원합니다.
git stash
1.
git stash : 현재 작업 내역을 임시로 저장합니다
2.
git stash list : stash 내역을 확인합니다
3.
git stash pop : stash 내역을 가져오고 stash를 삭제합니다
git stash pop stash@{0}
Bash
복사
4.
git stash apply : stash 내역을 가져오고 stash를 유지합니다
git stash apply stash@{1}
Bash
복사
5.
git stash drop : stash를 삭제합니다
git stash drop stash@{2}
Bash
복사
upstream에서 코드 가져오기
1.
git remote -v
2.
git remote add [origin] [address]
git remote add upstream https://github.com/owner/repository-name.git
Bash
복사
3.
git fetch [origin]
git fetch upstream
# (참고) 모든 remote origin의 코드 가져오기 (git fetch upstream + git fetch origin)
git remote update
Bash
복사
4.
git merge [origin/branch]
(@origin/develop) git merge upstream/develop
git checkout main
(@origin/main) git merge upstream/main
Bash
복사