Git 설치 및 환경설정

Weed·2024년 2월 16일
0

Git 설치

Git - Bash

CLI (Command Line Interface)

GUI (Graphics User Interface)

Git 명령어

git init
git config
git add [file or folder]
git commit -m [message]
git checkout [branch name]
git fetch [remote name]
git merge [branch name]
git remote
git pull
git push
git status
git log

gitignore

gitigore.io

# Created by https://www.toptal.com/developers/gitignore/api/macos,java,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,java,visualstudiocode

### Java ###
# Compiled class file
*.class # 자바의 컴파일 파일인 .class파일을 무시

# Log file
*.log #.log는 프로그램의 실행 정보를 남기는 파일을 무시

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files # 아래 파일같은 것들도 무시
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/macos,java,visualstudiocode

위 코드가 생성.

gitattributes

  • 파일들에 대해서 어떻게 그 파일들을 인식할 것인가 속성들을 지정
  • ex) *text=auto
  • xml파일이니 등 파일의 종류를 git이 인지하도록 해서 관리
  • 새 줄 문자, 정정할 텍스트 파일, 바이너리 파일을 명시적으로 지정
  • *text 파일은 자동
  • *.html은 text 파일로 명시적으로 지정
  • *.css는 text 파일로 명시적으로 지정
  • *.ico는 binary 파일로 명시적으로 지정

git config

git config levels

  1. --local: 프로젝트 단위별로 환경설정 (Repository 단위)
  2. --global: 모든 Repository에 대해서 환경설정
  3. --system: 내가 사용하고 있는 os에 대한 환경설정
$ git config --global user.name "username'
$ git config --global user.email "username@hostname"
$ git config --list # 환경 설정 내역을 확인
$ git config --global --list
$ git config --get user.name # 로컬 설정값 확인 (저장소별 설정)
$ git config --list # 위와 동일
$ git help config # 도움말

Mac OS .gitconfig 위치


정규표현식

  • 정규표현식: 애플리케이션과 프로그래밍 언어에 사용할 수 있는 특수한 텍스트 패턴
  • 입력 내용이 텍스트 패턴에 일치하는지 여부를 검사하거나 텍스트를 찾아낼 때 사용함
  • 참조사이트: https://regexr.com/


한글을 영어로 출력


위 사진처럼 git이 한글로 출력될 경우

  • 현재 설정 확인
$ echo $LANG

위 코드 확인 시 한국어로 설정된 것을 알 수 있다.

  • .zshrc 파일 수정
$ vim ~/.zshrc

Vim에서 위 문항을 찾으려면 /Lang를 치고 엔터키를 누르면 검색해준다.

기본적으로 LANG=en_US.UTF-8이 주석처리 되어있을텐데 이를 주석 처리 해제

$ source ~/.zshrc

위 명령어 실행 후 확인하면

영어로 복귀된 것을 알 수 있다.

다시 한글로 출력하려면

Git 파일 및 디렉토리

profile
개발자로 전직해보자

0개의 댓글