Make Unreal REAL.
article thumbnail
The Ultimate Git Course - with Applications in Unreal Engine

 

 

Repository 초기화

<bash />
# .git 폴더를 생성 git init

 

Repository 상태 확인

<bash />
git status

 

유저 이름 설정

<bash />
git config user.name 'USER NAME'

 

유저 이메일 설정

<bash />
git config user.email 'some@email.com'

 

기본 Branch 이름을 main으로 변경

<bash />
# master인 경우가 많은데 main으로 넘어가는 추세이다. git config --global init.defaultBranch main

 

경로 길이 제한 해제

<bash />
git config --system core.longpaths true

 

로컬, 시스템, 글로벌 config 모두 보기

<bash />
git config -l --show-origin

 

some.file의 새로운 변경 사항을 Stage

<bash />
git add some.file

 

모든 변경 사항을 Stage

<bash />
# git add --all git add .

 

Untracked (한 번도 add 한 적이 없는) 파일을 제외한 모든 변경 사항 Stage

<bash />
git add -u

 

some.file 삭제하고 Stage

<bash />
git rm some.file

 

가장 최근 commit의 내용으로 복원

<bash />
git restore some.file

 

Staging Area에 올라간 변경 사항 Unstaging

<bash />
# Staging Area에서 없어질 뿐, 변경 내용이 사라지는 것은 아니다. git restore --staged some.file

 

Staged 된 변경 사항을 로컬 Repository에 적용

<bash />
# 편집기에서 commit 메시지 작성 git commit # 편집기 없이 바로 전달 git commit -m "commit title" -m "commit description"

 

Untracked 파일을 제외한 변경 사항 Stage 후 commit

<bash />
# git add -u && git commit git commit -a

 

가장 최근 commit을 수정

<bash />
# commit 메시지만 수정하는 것이 아니라, 현재 Staged 된 변경 사항도 같이 적용된다. git commit --amend

 

commit된 수정 사항을 복원

<bash />
# Revert 또한 하나의 commit으로 처리된다. git revert COMMIT_ID

 

가장 최근 commit을 삭제

<bash />
# commit 기록을 삭제하는 것일 뿐, 내용을 복원하지는 않는다. git reset HEAD~

 

최근 n개의 commit을 삭제

<bash />
# commit 기록을 삭제하는 것일 뿐, 내용을 복원하지는 않는다. git reset HEAD~n

 

가장 최근 commit을 삭제하고 내용도 복원

<bash />
# git reset HEAD~ && git restore . git reset --hard HEAD~

 

commit 기록 확인

<bash />
git log

 

현재 Branch 확인

<bash />
# Local git branch # Local + Remote git branch -vv

 

새로운 Branch 생성

<bash />
git branch new_branch

 

현재 Branch 변경

<bash />
# 작업 폴더의 모든 파일들이 새로운 Branch에 맞춰 변경된다. git checkout new_branch # 새로운 Branch 생성 후 바로 변경 # git branch new_branch && git checkout new_branch git checkout -b new_branch ※ 변경 사항을 commit하지 않고 Branch를 변경하면, 변경 사항이 바뀐 Branch에 그대로 남게 되니 주의

 

현재 Branch에 다른 Branch를 병합

<bash />
git merge other_branch

 

Branch 삭제

<bash />
# main에 Merge하여 더 이상 필요 없는 경우 등 # Merge하지 않는 commit이 있으면 삭제되지 않는다. git branch -d old_branch # Merge하지 않은 commit이 있어도 강제 삭제 git branch -D old_branch

 

Branch 이름 변경

<bash />
# Case-insensitive git branch -m new_name # Case-sensitive git branch -M new_name

 

기존 Branch를 기반으로 새로운 Branch 생성

<bash />
git branch -m base_branch new_branch

 

Rebase

<bash />
git rebase base_branch

 

Interactive Rebase

<bash />
# COMMIT_ID_BEFORE 이후의 commit들을 묶는다. git rebase -i COMMIT_ID_BEFORE # 최근 2개 commit을 묶는다. git rebase -i HEAD~2

 

commit 간 스냅샷 차이 확인

<bash />
git diff COMMIT_ID_1 COMMIT_ID_2

 

Remote Repository 확인

<bash />
git remote

 

Local에 Remote의 origin을 추적하는 Remote Tracking Branch를 생성한다.

<bash />
git remote add origin git@github.com:username/repository.git

 

Local mybranch의 내용을 Remote origin/mybranch에 적용

<bash />
# 단발성 git push origin mybranch # Tracking connection # origin/mybranch를 Local mybranch의 Upstream으로 지정 # Local에 Remote mybranch를 추적하는 Remote Tracking mybranch Branch가 생성된다. # git branch --set-upstream-to=origin/mybranch mybranch git push -u origin mybranch ※ Tracking connection을 설정해 주지 않으면, Local Branch가 origin을 추적하지 않는다. ※ 향후 Push, Pull을 쉽게 할 수 없다.

 

Local의 내용으로 Remote origin을 강제로 덮어씀

<bash />
git push -f origin mybranch ※ 파일들과 commit 그래프가 덮어쓰기 되므로 필요한 경우에만 사용!

 

Remote Branch 삭제

<bash />
git push --delete origin mybranch

 

Remote Repository Clone

<bash />
# 내용을 Clone한 후 Remote Tracking Branch를 생성한다. git clone https://github.com/username/repository.git

 

Remote origin을 기준으로 Local의 Remote Tracking Branch를 갱신한다.

<bash />
git fetch

 

Local Repository에 Remote를 Merge

<bash />
# fetch, then merge git pull

 

Tracked 파일들의 변경 사항과 Staged 된 변경 사항을 Stash stack에 push

<bash />
# git stash push git stash

 

Untracked 상태인 파일들도 함께 Stash

<bash />
git stash --include-untracked

 

Staged 되지 않은 파일들만 Stash

<bash />
# Staging Area는 영향을 받지 않는다. git stash --keep-index

 

Stash stack의 top에 있는 stash를 확인

<bash />
git stash show

 

Stash stack의 top에 있는 stash를 버림

<bash />
git stash drop

 

Stash stack의 top에 있는 stash를 pop

<bash />
# Stash는 기본적으로 Staged 상태까지 복원해주지 않는다. # git stash apply && git stash drop git stash pop # Staged 상태까지 복원 # git stash apply --index && git stash drop git stash pop --index

 

다른 Branch에 있는 특정 commit만 가져와 적용하기

<bash />
# 작업 폴더의 내용이 바뀌며 commit hitory에도 추가된다. git cherry-pick COMMIT_ID

 

다른 Branch에 있는 특정 commit만 가져와 Stage시키기

<bash />
# 작업 폴더의 내용이 바뀌며 변경 사항은 Stage된다. git cherry-pick -n COMMIT_ID

 

.uasset 파일 LFS로 관리하기

<bash />
# .gitattributes # *.uasset filter=lfs diff=lfs merge=lfs -text git lfs track *.uasset

'Unreal Engine > The Ultimate Git Course in Unreal Engine' 카테고리의 다른 글

Git에서 파일이 관리되는 방식  (0) 2023.01.18
Git 설정 파일들  (0) 2023.01.18
Git이란?  (0) 2023.01.18
버전 관리란?  (0) 2023.01.18
버전 관리를 해야하는 이유  (1) 2023.01.18
profile

Make Unreal REAL.

@diesuki4

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!

검색 태그