일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
31 |
- 임베딩
- 전처리
- Fine-tuning
- 21주차
- 회고록
- #include
- 배포
- openai
- AWS
- 최종프로젝트
- Docker
- zero-shot
- sk네트웍스familyai캠프12기
- ai캠프
- FastAPI
- sk네트웍스familyai캠프
- sk네트웍스family
- C++
- one-shot
- 컴파일
- few-shot
- 12기
- 중복인클루드
- Langchain
- Rag
- sk네트웍스ai캠프
- 어셈블
- 헤더가드
- 주간회고
- 소스코드
- Today
- Total
ansir 님의 블로그
Git Bash를 이용한 Git&GitHub 관리 본문
테스트, 형상관리( Git )
폴더 생성: mkdir
폴더 생성하기
mkdir git_test
깃 초기화: git init
git init
폴더 내 목록 확인: ls
ls -all
터미널 코드 삭제: clear
clear
파일 생성: echo
echo ‘test’ >> first.txt
Staging Area에 수정된 파일 올리기: git add
git add first.txt
- >특정 파일만( first.txt ) 올리기
git add .
→ 전체 파일 올리기
💡파일 명은 되도록 전부 입력하지 말고 탭으로 자동완성 하기
git 상태 확인: git status
git status
Staging Area에서 내리기: git rm --cached or git restore --staged
git rm --cached first.txt
git restore --staged first.txt
git 권한
git 로컬 권한은 한 번 설정이 되면 계속 유지되기 때문에 자신의 것으로 설정되어 있는지 확인해야 한다.
만약 다른 사람의 권한으로 git을 사용하게 된다면 원격 또는 로컬 저장소에 다른 사람의 정보로 정보가 올라가게 되며, 다른 사람이 자신의 저장소에 접근하게 될 수도 있다.
로컬 권한을 확인하는 방법
로컬 권한을 확인하는 방법은 윈도우의 자격 증명 관리자에서 확인할 수 있다.
권한 설정
git config --global user.name ‘user_name’
git config --global user.email ‘user_email’
Commit
git commit -m “first commit”
로그 확인: git log
git log
author: 올린 사람
data: 올린 날짜
커밋 메시지
를 확인할 수 있다.
--oneline
git log --oneline
깃 로그 간략하기 보기
원격 리포지토리 등록하기: git remote add origin
git remote add origin [ git url ]
원격 리포지토리에 올리기: git push origin
git push origin [ origin branch name ]
특정 커밋 내용 되돌리기: git revert
git revert [ commit hash ]
commit hash 확인하는 방법
git log --oneline
에서 commit message 앞의 코드가 commit hash이다.
💡특정 부분을 드래그하고 마우스 휠을 클릭하면 커서 위치에 내용이 붙여넣기가 된다.
특정 커밋 revert를 되돌리기
특정 커밋 a를 revert하여 새로운 커밋 b가 생성되었을 때, revert한 커밋 a를 다시 되돌리려면
새롭게 만들어진 커밋 b를 revert하면 된다.
git revert b_hash
git checkout
checkout은 브랜치도 되지만 커밋으로도 이동 가능하다.
git checkout 1e734e9
Note: switching to '1e734e9'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
git checkout -b [ new_branch_name ]
-b
설정을 추가하면 새로운 브랜치를 추가하고 그곳을 가리키도록 한다.
특정 커밋으로 돌아가서 새로운 브랜치 나누기
- 특정 커밋 hash로 checkout:
git checkout [ commit hash ]
git checkout -b [new_brach_name ]
으로 새로운 브랜치 생성
새로 나눈 브랜치 병합
- 작업 내용 Staging&Commit
git push origin [ new_branch_name ]
( new_branch_name은 원격 저장소에 올릴 이름임 )- 깃허브로 가서 Pull Request 요청
- 병합 후 원격 new_branch_name 브랜치 삭제
원격 저장소의 브랜치 삭제하기
- 원격 저장소에서 브랜치 삭제:
git push origin --delete branch_name
- 로컬에 남아있는 원격 추적 브랜치 제거:
git fetch --prune
→ 원격에서 삭제된 브랜치 정보를 로컬에서도 정리해준다.
또는,
수동으로 브랜치 제거:git branch -dr origin/branch_name
-d
: 브랜치 삭제-r
: remote-tracking 브랜치 대상으로