설정 범위
git config —system : (시스템범위) 시스템의 모든 사용자와 모든 저장소에 적용git config —global : (사용자별) 시스템의 특정 사용자에게 적용git config —local : (저장소별) 특정 저장소에 적용사용자 정보 - global 옵션
git config user.name <user_name>
git config user.email <email_address>
CFLF ( End of Line )
git config core.autocrif <value>
라인의 끝을 표기하는 문자 ( 줄바꿈 문자 )
Editor
git config core.editor <deitor_name>
Default Branch
git config init.defaultBranch <branch_name>
전체 설정 확인
git config --l(영어 소문자 L)
git config —list
git config --l --show-origingit config --list --show-origingit config <key>Git Repository
Git으로 관리하는 프로젝트 저장소
파일과 디렉토리 포함 가능. 버전관리 시작 가능
방법
git init 프로젝트 폴더를 git 저장소로 만들어
git initgit clone remote 저장소를 local에 복사하여 사용
git clone <remote_repository_url>
# https://github.com/<organication_name>/<project_name>.git
git clonegit initgit clone https://**<token>@**github.com/<user_name>/<project_name>.git★★★ git status | Working Directory, Staging Area 상태 표시 파일 상태 확인 시 |
git add <file_name> | - Working Directory → Staging Area(Index) 추가 - Modified → Staged 파일을 Commit 대상으로 바꿀 때 |
★★★git commit -m <commit_message>git commit -a -m <commit_message>= git commit -m <message> <파일명> | <commit_message> - 통해서 version 찾음, 의미있는 문구 작성, 되도록 영문 -a 옵션 : add + commit ( Modified → Committed ) |
git ignore | Git에서 무시해야 하는 파일패턴 관리 |
git rm <file_name> | Git에서 관리하는 파일 삭제 (Staging Area의 파일삭제 + commit ) - Working Directory에서 삭제됨 |
rm <file_name> | Git 말고 Working Directory에서 바로 삭제 → unstaged 상태 →→ git rm +commit 해줘 |
git mv <old_name> <new_name>= cp <old_name> <new_name>git rm <old_name>git add <new_name> | Git에서 파일이름(경로 포함) 변경 = 파일 복사 원본 파일 삭제 Git Add |
| Git Log 문법 | |
git log | commit history 나옴 |
git log -2 | 최근 2개의 commit history |
git log —skip 5 | 가장 앞 5개의 commit을 스킵 후 보여줘 |
git log -p | diff 포함해서 출력 |
git log —oneline | logID(앞7자리) + message 만 각각 한 줄로 출력 |
git log —author=<user_name or user_email> | commit한 사용자로 검색 |
git log -S <파일변경내용> | 파일 변경내용으로 검색 |
git log --grep <commit message> | commit message로 검색 |
*.a 확장자가 .a 인 파일 무시!lib.a 위에서 .a 확장자 파일 무시 했지만 lib.a는 무시하지 X/TODO 현재 디렉토리에 있는 TODO 파일무시, subdir/TODO처럼 하위디렉토리의 파일은 무시Xbuild/ build/디렉토리의 모든 파일 무시doc/*.txt doc/notes.txt 파일 무시, doc/server/arch.txt 파일 무시 Xdoc/**/*.pdf doc디렉토리 아래모든 .pdf 파일 무시| 파일 수정 문법 | |
|---|---|
touch 파일명 | untracked file 생성 |
git add * | 조심해 !!!!! 사용하지마 |
cat 파일명 | 파일 내용 출력 |
cat > 파일명 + ctrl D | 아래 타이핑 한 내용으로 파일을 덮어 써 |
cat >> 파일명+ ctrl D | 아래 타이핑 한 내용을 파일에 추가해줘 |
| Remote Repository 문법 | |
|---|---|
git remote add <remote_repo명> <remote_repo url>git remote add origin <remote repo url> | 연결할 remote repository 관리 가장 중요한 remote repo 명 = origin으로 해 |
git remote set-url origin <remote repo new url> | remote repository url 수정 |
git remote rename <old_name> <new_name> | remote repository 이름 수정 |
git remote remove <remote repo명> | remote repository 삭제 |
git remote -v | remote repository 정보 확인 |
| (token 등록 해두었을 시 노출될 수 O) | |
git remote show <remote repo명> | remote repository 상세보기 |
git pull <remote repo명> <branch명>( git pull origin main) | remote repository 작업 내용 → local repository 에 동기화 <⇒ Fetch(download)와 Merge(기존의 것과)의 과정 |
git push <remote repo명> <branch명>( git push origin main) | local repository에서 작업한 내용을 remote repository에 배포하고 싶을 때 |
Checkout & Branch
git checkout <commit_id> | 특정 버전으로 이동 |
git branch | branch 목록 보기 (local의) + 현재 branch 확인 |
git branch -r | branch 목록 보기 ( remote의) |
git branch -a | branch 목록 보기 ( local + remote ) |
git branch branch명 | (Local) HEAD가 가리키는 곳에 branch 생성 |
git push origin branch명 | 서버에 branch 배포 |
git branch --delete branch명 | (Local) branch 삭제 |
git push origin --delete branch명 | (Remote) branch 삭제 |
git checkout branch명 | branch 간 이동 |
git checkout -b branch명 | branch 생성 + 이동 |
Merge & Conflict
git merge <branch_name><<<<<<<< HEAD
print("Hello, cat!")
======== # ->충돌부분 기준
print("Hello, dog!")
>>>>>>>> HEADprint("Hello, cat!")git add <conflict_file_name>git commit -m <merge_message>git commit -i로 강제 commit 가능git tag <tag_name>
git tag | Tag 목록 조회 |
|---|---|
git tag tag명 <commit_id> | 지나간 것에 대해 tag할 때 |
git push origin <tag_name> | Tag 배포 |
git show tag명 | Tag 상세정보 조회 |
git tag --delete tag명 | (Local) Tag 삭제 |
git push origin --delete tag명 | (Remote) Tag 삭제 |
: 프로젝트에 대한 설명, 사용방법, 라이센스, 설치법 등에 대해 기술하는 파일
★★★ git으로 포트폴리오 관리하는 것 중요
| 제목 | # 제목1 ## 제목2 ### 제목3 #### 제목4 ##### 제목5 ###### 제목6 |
|---|---|
| 인용 | > 인용문 >> 인용문의 인용문 |
| 숫자목록 | 1. 2. 3. |
| 목록 | * , + , - |
| 코드 | ` 코드 ` = 코드 ``` 코드 ``` = |
| 구분선 | *** --- |
| 링크 | [단어] 링크 <링크> <이메일> |
| 기울임 | * 글자 * _ 글자 _ |
| 굵게 | ** 글자 ** __ 글자 __ |
| 취소선 | ~~ 글자 ~~ |