Git and Github Tutorial (깃, 깃허브 제대로 배우기)

River·2023년 3월 24일
0

Git & Github

목록 보기
1/2

드림코딩 git & github

git이란?

명령어를 기본으로 한 명령어 프로그램
Git 공식 홈페이지

  • GUI tools
    • Sourcetree
    • GitKraken
    • etc
  • Terminal
    • macOS - iTerm2
    • windows - cmder

git 설치

Git 공식 문서 참고

  • macOS 는 아래의 명령어로 설치 여부 확인 가능
	git --version

git 명령어

Git 명령어 문서

git config --list 
// 모든 설정 확인 가능 
git config --global -e
// config 파일 edit 
  • VScode 사용하여 edit 하고 싶다면

    Open VScode > command palette > >code > Shell command Install'code' command in PATH

git config --global core.editor "code"
git config --global -e 
code . 
git config --global core.editor "code --wait" 
// wait 옵션 주었기에 VScode 로 열린 파일 종료되기 전까지 다른 명령어 수행 불가능
  • 사용자 환경 설정
git config --global user.name "username"
git config --global user.email "useremail"
git config user.name 
git config user.email

core.autocrlf input or true

macOS

  • Line feed ('\n')하나만 들어감

windows

  • Carriage return('\r') & Line feed ('\n')동시에 들어감

macOS이면 input, windows면 true

git config --global core.autocrlf input

git config --global alias

  • 반복해서 자주 쓰는 명령어를 간단하게 치고 싶다면
git config --global alias.st status 
  • status -> st 로 간편하게 바꿔 사용 가능
  • 만약 oh-my-zsh 를 설치했다면 gst 만 쳐도 git status 랑 동일하게 동작!
  • git add
    • Untracked -> Staging area

  • git add *
git add *.txt  
// *: 디렉토리의 모든 파일 의미
// txt 파일 전체 Staged
  • git rm --cached
    • Staging area -> working directory(Unstage)
    • Untracked

gitignore

  • log 파일들 모두 깃헙에 안 올리고 싶어! 라면 gitignore 에다가 전부 넣어버리기
echo *.log > .gitignore 
  • If, 특정 폴더 안에 log 파일들을 보고 싶지 않다면
echo build/*.log > .gitignore

git st -s (git status -s)

  • short 간단하게 보여줌


  • A b.txt
    • b.txt add, 현재 Staging area
  • M c.txt
    • c.txt add, 현재 Modified
  • ?? .gitignore
    • 현재 Untracked, Working directory

git diff

  • Staging area 에 있는 것을 확인하고 싶을 때
git diff --staged
  • 누가 작성했는지, 언제, 타이틀, description
git log 

git add -u

  • 삭제된 파일, 폴더 반영하기
// 삭제한 파일, 폴더를 반영하고 싶을 때 
git add -u
git commit -a -m "Delete"
git push af main

git directory 에는 어떤 커밋을 해야할까?

  • commit 은 의미있는 작은 단위로 진행
  • commit message는 현재형 동사로 작성
  • commit message 에 해당하는 내용만 포함하여 commit
profile
Passionate about My Dreams

0개의 댓글