Git 명령어

Dec 12, 2023
Git 명령어
 
ls -a : 폴더의 파일목록 확인
notion image
 
git init : 저장소를 만드는 것 초기화
notion image
 
git add. : commit 하기 위한 준비과정
notion image
 
git commit -m “~~” : add 과정에서 임시저장 해 둔 것을 확정하는 것 스냅샷을 남김
notion image
notion image
 
💡
사용자 초기 설정을 해주자 - 처음 사용 시 한번 입력해야 함
git config --global user.email "j910219[@gmail.com](mailto:you@example.com)" git config --global [user.name](http://user.name/) "test231212"
notion image
notion image
notion image
notion image
다시 commit
notion image
 
git log : commit 해둔 내역을 확인하고 싶을 때
notion image
 
rm -r .git : 내부의 폴더도 함께 삭제, 진짜 삭제할껀지 한번 더 물어봄
💡
-(하이픈)하나일 때 약어, 하이픈 두개일 때 풀네임
notion image
 
rm -rf .git : 내부 폴더를 삭제할 때 묻지않고 바로 삭제
notion image
 
git remote add origin 주소 : 깃허브 주소를 origin으로 추가한다
notion image
💡
깃허브에서 주소 가져와서 입력 git remote add origin https://github.com/Test231212/java-lec-study.git
notion image
 
git remote -v : 로컬 컴퓨터에서 원격지에 연결
notion image
git push origin master : origin 으로 commit들을 올린다
notion image
 
직접 추가해보기 add→commit→push
notion image
notion image
notion image
git status : 현재 상태 확인하기
notion image
git branch test : "test"라는 이름의 branch 생성
notion image
notion image
notion image
notion image
git checkout test로 test branch로 전환 할 수 있다
notion image
notion image
git checkout master로 master로 전환 할 수 있다
notion image
notion image
💡
브랜치 이동 시 커밋해야함

나타날 수 있는 오류

 
notion image
💡
윈도우 환경 Path 설치가 제대로 되었는지 확인, [windows 설정]-[시스템]-[정보]-[고급 시스템 설정]-[환경 변수]-[Path] 없으면 설정하기
  • 설정하는 방법 - 환경 변수 Path에 cmd 나 bin 주소를 복사 붙여 넣기
notion image
설정한 후 재부팅 필수
설치가 되었는지 확인
 
notion image
  • git remote -v 사용하기 (원격지 연결 확인하는법)
 
Share article

Essential IT