본문 바로가기

Git

Git 명령어 모음

git init

.git 이라는 하위 디렉토리를 만든다. .git 디렉토리에는 저장소에 필요한 뼈대 파일(Skeleton)이 들어 있음.

 

git config --list

git 설정 리스트

 

git ls-files --others --exclude-standard

untracked 파일 목록 조회. (stage 전 단계의 파일들)

 

git add . (recommend git add -p)

모든 untracked 파일들을 stage 상태로 전환

p 옵션을 붙이면 하나씩 차례대로 변경부분을 보여주며, staging 할건지 물어봄

하지만 새로운 파일에는 적용이 안됨. 고로, 새로 프로젝트 생성했을 때는 사용못함. 

(staging에 대해 물어볼 때, 여러 옵션이 있지만, y/n/q 정도만 알아도 될듯 -> yes/no/quit)

 

* git add시에 아래와 같은 에러가 발생할 수 있습니다. 

warning: LF will be replaced by CRLF in some/file.file. The file will have its original line endings in your working directory.

whitespace에러로, 한 줄의 끝이 유닉스 시스템은 LF(Line Feed), 윈도우는 CRLF(CR(Carriage Return), LF)로 이루어지기에 이 부분이 혼동되어 발생하는 에러입니다. 

해결방법은 core.autocrlf 기능을 키면 됩니다.

window : git config --global core.autocrlf true
linux     : git config --global core.autocrlf true input

자세한 사항은 아래 블로그에서 확인하실수 있습니다.

ref) https://blog.jaeyoon.io/2018/01/git-crlf.html

 

git commit -m 'commit name'

stage 상태의 파일들을 commit 하기

 

git remote add origin git_url

원격 저장소 연결하기

 

git push origin branch_name

해당 브랜치를 연결된 원격 저장소에 올리기

 

git pull origin branch_name

해당 브랜치 가져와서 merge하기

 

git clone git_url

해당 url의 repository를 복제한다.

 

git branch branch_name

브랜치 생성하기

 

git checkout branch_name

해당 브랜치로 바꾸기

 

git checkout -b branch_name

브랜치 생성 후 생성된 브랜치로 이동

 

git config --global user.name "GilDong Hong"

git config --global user.email "google@gmail.com"

사용자 정보 설정하기

 

git stash

커밋하기엔 작업이 안끝났고, 다른 브랜치로는 넘어가야겠을 때 사용!

'Git' 카테고리의 다른 글

[Git] Pull Request  (0) 2020.06.25
Github readme.md에 이미지 업로드 하기  (0) 2020.06.12