[GIT] 버전 관리란 & git 설치하기

Soo·2023년 10월 3일
0
post-thumbnail

✏️ 버전 관리 (형상 관리/ 소스 관리)

💡 버전 관리란?

소프트웨어의 변경사항을 체계적으로 추적하고 통제하는 것

  • Version Control Sytem (버전관리 시스템)
    (밑줄 : 현업에서 많이 사용하는 툴)
    • CVCS = CVS, SVN, etc…
    • DVCS = Mercurial, Git, etc…
  • Configuration Management System (형상관리 시스템)

💡 장점

  • 협업에 유용하다.
  • 개발자 모두가 모두 분산처리 서버의 주인임으로 빠르게 일을 처리할 수 있다.
  • history 추적이 가능하다.
  • 로컬 서버로 오프라인 작업이 가능하다. (다른 개발자에 영향 없음 + 일시적인 서버 장애에도 개발 진행 가능)

✏️ GIT

💡 대표 서비스

  • github
    • Git을 호스팅 해주는 웹 서비스, 협업을 위한 기능을 제공
    • 참고 - 소스코드 보안이 중요한 경우 사용을 기피함
  • gitlab
    • 설치형 버전관리 시스템 - 소스코드 보안이 중요한 기업에서 주로 사용
    • 클라우드 버전관리 시스템 - 10명이하무료(Github와유사)
    • Issue tracker, Git Remote Repository, API, Team, Group 기능 제공

💡 GIT 설치하기 (For MAC M1)

1. 설치여부 확인 (at 터미널)

설치되어 있다면 pass 난 이미 설치되어 있어 이후 과정은 진행하지 않아 아래 과정 진행하지 않음

git  --version

2-1. Homebrew 설치

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2-2. 터미널 이동 후 아래 입력

% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2-3-1. zsh: command not found 에러가 발생한다면

% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
zsh: command not found

# 홈브루를 /opt 디렉토리에 설치하기 위해 이동
% cd /opt

# 루트 권한으로 homebrew 폴더를 만든다
% sudo mkdir homebrew

# homebrew 폴더의 루트 권한을 유저로 바꿔준다
% sudo chown -R $(whoami) /opt/homebrew
//sudo chown -R 유저명 경로 = 경로의 권한을 유저한테 준다는 뜻

# homebrew 다운로드
% curl -L https://github.com/Homebrew/brew/tarball/
master | tar xz --strip 1 -C homebrew

# homebrew bin 디렉토리를 PATH에 추가
% echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc

# homebrew 홈페이지에 있던 명령어를 이제 실행!
% /bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/nrubin29/
bea5aa83e8dfa91370fe83b62dad6dfa/raw/
48f48f7fef21abb308e129a80b3214c2538fc611/homebrew_m1.sh)"
Copyright zerobase Corp. All Rights Reserved

# 설치완료

2-3-2. Password (Mac) 입력 후 Enter

% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/
install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password).
Password:

2-4. 설치 중 enter 누르기

Press RETURN to continue or any other key to abort

2-5. Password (Mac) 입력후 Enter

...
Downloading Command Line Tools for Xcode
Downloaded Command Line Tools for Xcode Installing Command Line Tools for Xcode
Done with Command Line Tools for Xcode
Done.
==> /usr/bin/sudo /bin/rm -f /tmp/
.com.apple.dt.CommandLineTools.installondemand.in-progress
Password:

2-6. 설치 완료

...
==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
%
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/insang/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- Run `brew help` to get started
- Further documentation:
https://docs.brew.sh
%

3-1. brew로 git 설치하기 (at 터미널)

% brew install git
.... 
Emacs Lisp files have been installed to:
/opt/homebrew/share/emacs/site-lisp/git
%

3-2. zsh: command not found: brew 에러가 발생한다면

% brew install git
zsh: command not found: brew
% eval "$(/opt/homebrew/bin/brew shellenv)"
% brew install git
....
Emacs Lisp files have been installed to:
/opt/homebrew/share/emacs/site-lisp/git
%

3-3. 설치여부 확인

git  --version

💡 GIThub 가입후 git configuration

1. 터미널에서 아래 개인 정보 입력

git config --global user.name <username>
git config --global user.email <email>

예시 >>
% git config --global user.name zerobasegit
% git config --global user.email zerobase.git@gmail.com

2. CRLF

for mac

% git config --global core.autocrlf input

for window : 가져올 때는 LF 를 CRLF 로 변경하고 보낼때는 CRLF 를 LF 로 변경
-LF가 기본 통용임으로 윈도우-맥 유저간 협업 작업을 위해 LF로 변경하고 보내는 설정 필수
-그렇지 않으면 CRLF 차이로 인해 commit 이 발생할 수 있음

% git config --global core.autocrlf true

3. editor

아래 "💡 Editor"에서 추가 설명

git config --global core.editor <editor>

>> 예시
% git config --global core.editor vim

4. 전체 설정 확인

% git config --list

>> 예시
% git config --list credential.helper=osxkeychain
user.name=<username>
user.email=zerobase.<email>
core.editor=vim
core.auticrlf=true

💡 Editor

git config --global core.editor <editor>

>> 예시
% git config --global core.editor vim
  • --wait 옵션 : command line으로 VScode를 실행했을 경우, VScode를 닫을 때까지 command 대기 (터미널에 명령 입력 안됨)
git config --global core.editor <editor> --wait
  • 현재 config 확인하는 코드
% git config --global core.editor
  • VScode로 변경하기
% git config --global core.editor "code --wait"
  • 설정된 editor 상세 옵션 수정할수 있는 창
    • 위 명령으로 VS코드로 변경후 아래 코드 입력하면 VS코드가 열림
    • vim상태에서도 수정할 수 있으나 가독성이 떨어짐
% git config --global -e
  • 창에 들어간 후 아래 코드로 tool 설정하기
    [diff]
        tool = vscode
    [difftool "vscode"]
        cmd = "code --wait --diff $LOCAL $REMOTE"
    [merge]
        tool = vscode
    [mergetool "vscode"]
        cmd = "code --wait $MERGED"

✏️ 출처

제로베이스 데이터취업스쿨 강의
형상관리에 대해서... SCM, VCS, SVN, git...
나무위키_git

profile
데린이인데요 ໒꒰ྀ ˶ • ༝ •˶ ꒱ྀིა (잘못 된 부분은 너그러이 알려주세요.)

0개의 댓글

관련 채용 정보