Git 명령어

duckbill413·2023년 10월 20일
0

Git

목록 보기
1/2
post-thumbnail

Git 설치와 초기 설정
자주 사용하는 Git 명령어에 대해서

GIT

Git 설치

Git (git-scm.com)

Git 설치 확인 및 설정

  • $ git --version
  • $ git config --global [user.name](http://user.name) "username"
  • $ git config --global [user.name](http://user.name) "user email"
  • Window에서 Git에 저장할 때는 “text\n” git에서 Window로 가져올 때는 “text\r\n”
    • $ git config --global core.autocrlf true
  • Mac에서는 양방향 모두 “text\n”으로 처리
    • $ git config --global core.autocrlf input

git 설정 확인

  • $ git config --list [ 확인 종료 : -q]

Local Repo.

git command

git repository 생성

  • git bash 실행
  • 일반 director를 git repository로 변경
  • 생성 : $ git init
  • 제거 : $ rm -rf.git

status

$ git status

add

  • $ git add a.txt
    • a.txt를 untracked(git의 비관리대상)에서 tracked(git의 관리대상)으로 변경.
    • staging area로 이동(commit이전 상태)
  • $ git status
  • $ git add [File Name]
  • $ git add . 전체 파일을 스테이징 상태로 이동

remove

  • $ git status
  • $ git rm -cached <filename> : file을 다시 untracked 상태로 되돌림

git ignore

  • git staging 에 올리는 것 제외시키기.
  • $ echo debug.log > .gitignore : .gitignore에 파일에 제외시킬 파일 추가
    • git ignore 설정 도움 사이트
    • git status -s : 간단 정보 출력

diff [--staged]

  • 변경 파일 정보.
  • $ git diff : working directory의 변경 내용 확인
  • $ git diff --staged : staging area의 변경 내용 확인

Commit

  • $ git commit -m "<commit message>"
    • $ git commit -am "initial commit": working directory의 모든 파일을 commit

Remote Repo.

Local-Remote Repo 연결

  • $ git remote add <name> <url>

Remote Repo project download

  • $ git clone <url>

push & pull

  • $ git push <name> <branch>
  • $ git pull <name> <branch>
profile
같이 공부합시다~

0개의 댓글