git starter를 위해

froajnzd·2022년 11월 3일
0

git

목록 보기
1/5

본 게시물은 git documentation을 기반합니다.
https://git-scm.com/docs/git
글쓴이가 보기 위해 작성한 게시물이므로 다소 성의가 없을 수 있습니다..

기본 준비 사항

  • git 설치

1. Start git bash

git을 사용할 directory에서 우클릭-> Git Bash Here 클릭
git bash 창이 뜬다.

## 이동
cd [이동하고자 하는 폴더 경로/명]
cd ..	# 상위 디렉토리로 이동
cd ~	# 홈디렉토리로 이동
cd -	# 이전에 있던 디렉토리로 이동

## 파일 목록 출력 
ls		## git bash, linux에서 사용
ls -a	# 숨겨진 파일이나 디렉토리 모두 출력
ls -l	# 자세한 내용(퍼미션, 소유자, 그룹 등) 출력
ls -al	# l과 a 옵션을 같이 적용 (l, a 순서는 상관없음)

dir		## Windows 터미널에서 사용 

아주 간단하게 설명한 위 명령어를 이용해서 깃을 사용하고자 하는 폴더로 진입한다.

2. Git Command Synopsis

git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
    [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
    [-p|--paginate|-P|--no-pager] [--no-replace-objects] [--bare]
    [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
    [--super-prefix=<path>] [--config-env=<name>=<envvar>]
    <command> [<args>]
옵션설명
-v , --version버전 출력
-h , --help도움말, 시놉시스 출력, 자주 사용하는 명령어 출력
-C "path"현재 디렉토리 대신 /path/에서 실행
-c "name"="value"git config parameter를 넘김
--exec-path[="path"]GIT_EXEC_PATH 대신 실행 경로를 지정
--html-pathgit의 HTML 문서가 설치된 경로를 출력
--man-path매뉴얼이 있는 경로를 출력
--info-pathInfo 파일이 있는 경로를 출력
-p, --paginate표준 출력이 터미널인 경우 모든 출력을 less(또는 설정된 경우에는 $PAGER)로 pipie
-P, --no-pagergit output을 pager로 pipe하지 않음
--no-replace-objectsgit object 대체를 위한 replacement refs를 사용하지 않음
--bare레포지토리를 bare 레포지토리로 취급. GIT_DIR 환경이 설정되지 않은 경우, 현재 디렉토리로 설정됨
--git-dir="path"git 레파지토리(.git이 있는 폴더)를 설정
--namespace="name"namespace 경로 설정
--config-env="name"="envvar"-c 처럼 환경변수를 넘김
--literal-pathspecspathspecs를 문자그대로 취급. GIT_LITERAL_PATHSPECS=1 과 같음
--glob-pathspecs"glob"를 모든 pathspecs에 추가. GIT_GLOB_PATHSPECS=1 과 같음
--noglob-pathspecs"literal"을 모든 pathspecs에 추가. GIT_NOGLOB_PATHSPECS=1 과 같음
--icase-pathspecs"icase"을 모든 pathspecs에 추가. GIT_ICASE_PATHSPECS=1 과 같음
--no-optional-lockslock이 필요한 옵션을 수행하지 않음. GIT_OPTIONAL_LOCKS=0 과 같음
--attr-source="tree-ish"worktree 대신 tree-ish의 gitattributes를 읽음

3. Git Command (usually use)

  • 새로운 Git Project 생성
commandexplanation
git clone [source-address]Clone a repository into a new directory
git initCreate an empty Git repository or reinitialize an existing one
  • Git Branch (분기)
commandexplanation
git branchList, create, or delete branches
git checkout [branch-name]Switch branches or restore working tree files
git switch [branch-name]Switch branches
  • Git Pull/Push
commandexplanation
git pullFetch from and integrate with another repository or a local branch
git add *(or [filename])Add file contents to the index
git commit (-m "[message]")Record changes to the repository
git pushUpdate remote refs along with associated objects
  • Git Log 관련
commandexplanation
git worktreeManage multiple working trees

4. Git HEAD 위치

내가 위치한 커밋 or 브랜치

5. Conflict

  • conflict가 발생하는 상황

같은 부분에서 변경이 일어났을 때, Git이 auto merge를 못한다.
이 때 conflict가 발생한다.

즉, git이 자동 병합을 못해 사용자가 직접 변경을 병합하도록 하는 것

cf. 3-way merge

profile
Hi I'm 열쯔엉

0개의 댓글