Git Add & Commit

이다연·2021년 3월 3일
0

Git & GitHub

목록 보기
1/8

mkdir 로 프로젝트 디렉토리 만듬

git init

git init
앞으로 버젼관리할 것이니 빈 리포지토리 (저장소)를 만들어라.
.git: 레포지토리

Commit

커밋한 순간의 프로젝트 디렉토리 모습을 하나의 버젼으로 기록

1. 깃에게 커밋한 사람 알려주기

git config user.name "name"
git config user.email "email@mail.com"

2. 커밋할 파일 미리 지정: git add file

git add calculate.py <파일 이름>
git add License

3. 커밋 메세지 추가: git commit -m " "

git commit -m "Create calculate.py and License"
현재형 동사 메세지

(root-commit): 첫번째 커밋이라는 뜻
2files changed, 7 insertions -> 변경된 사항 정보

3가지 작업영역

1. working directory == working tree

작업을 하는 프로젝트 디렉토리
git add <파일이름>으로 선별적으로 staging area로 옮길 수 있다.

2. staging area == index

git add를 한 파일들이 존재하는 영역

3. repository

.git 디렉토리가 repository

커밋들이 저장되는 영역. working directory의 변경 이력들이 저장되어 있는 영역입니다.

git add [directory name]

전체 디렉토리를 staging area에 추가해줌

git status

문제 상황 파악위해 사용!
e.g.
calculator.py만 add하고 License는 안해준 상황

git status

Changes to be committed: 
	modified: calculator.py

Changes not staged for commit:
	modified: License

git add .

현재 프로젝트 디렉토리 내에 변경 사항이 있는 모든 파일을 한번에 staging area로 올림

git reset

staging area 에서 제거
but, 변경된 새 모습은 그대로 working directory에 남아있음
git reset calculator.py

git help [커맨드 이름]

e.g. git help add
-> 공식 메뉴얼 출력
나가고 싶으면 quit(나가다)의 줄임말인 q를 입력


Cheat Sheet

git init :
현재 디렉토리를 Git이 관리하는 프로젝트 디렉토리
(=working directory)로 설정하고 그 안에 레포지토리(.git 디렉토리) 생성

git config user.name 'codeit' :
현재 사용자의 아이디를 'codeit'으로 설정
(커밋할 때 필요한 정보)

git config user.email 'teacher@codeit.kr' :
현재 사용자의 이메일 주소를 'teacher@codeit.kr'로 설정
(커밋할 때 필요한 정보)

git add [파일 이름] : 
수정사항이 있는 특정 파일을 staging area에 올리기

git add [디렉토리명] : 
해당 디렉토리 내에서 수정사항이 있는 모든 파일들을 staging area에 올리기 

git add . : 
working directory 내의 수정사항이 있는 모든 파일들을 staging area에 올리기

git reset [파일 이름] : 
staging area에 올렸던 파일 다시 내리기

git status : 
Git이 현재 인식하고 있는 프로젝트 관련 내용들 출력
(문제 상황이 발생했을 때 현재 상태를 파악하기 위해 활용하면 좋음) 

git commit -m "커밋 메시지" : 
현재 staging area에 있는 것들 커밋으로 남기기

git help [커맨드 이름] : 
사용법이 궁금한 Git 커맨드의 공식 메뉴얼 내용 출력

git push -u origin master : 로컬 레포지토리의 내용을 처음으로 리모트 레포지토리에 올릴 때 사용합니다.(-u origin master가 무슨 뜻인지는 'Git에서 브랜치 사용하기' 챕터에서 배울 거니까 걱정마세요!)

git push : 로컬 레포지토리의 내용을 리모트 레포지토리에 보내기 

git pull : 리모트 레포지토리의 내용을 로컬 레포지토리로 가져오기

git clone [프로젝트의 GitHub 상 주소] : GitHub에 있는 프로젝트를 내 컴퓨터로 가져오기


from 코드잇 Git 강의

[Git 경고 메세지] LF will be replaced by CRLF in 해결 방안

git config --global core.autocrlf true

https://dabo-dev.tistory.com/13

profile
Dayeon Lee | Django & Python Web Developer

1개의 댓글

comment-user-thumbnail
2024년 4월 5일

The error message "Reverse for merge fruits'' not found. '' is not a valid view function or pattern name" typically occurs when there is an issue with specifying the URL in Django templates.

답글 달기