๐ท Git repository ์์ฑ
๐ถ document
Git - Git ์ ์ฅ์ ๋ง๋ค๊ธฐ
2.1 Git์ ๊ธฐ์ด - Git ์ ์ฅ์ ๋ง๋ค๊ธฐ Git์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ์๊ณ ์ถ์๋ฐ ํ ์ฑํฐ๋ฐ์ ์ฝ์ ์๊ฐ์ด ์๋ค๋ฉด ์ด๋ฒ ์ฑํฐ๋ฅผ ์ฝ์ด์ผ ํ๋ค. Git์์ ์์ฃผ ์ฌ์ฉํ๋ ๋ช ๋ น์ด๋ ๋ชจ๋ 2์ฅ์ ๋ฑ์ฅํ๋ค. 2์ฅ์ ๋ค
git-scm.com
- git ํ์ด์ง์์๋ ์์ ๋๊ฐ์ง ๋ฐฉ๋ฒ์ด ๋์์๋ค.
- 2๊ฐ์ง ๋ฐฉ๋ฒ + vscode์์ ์ ๋ํฐํ๋ก์ ํธ๋ฅผ ํฌํจํ git ๋ ํ์งํ ๋ฆฌ๋ฅผ ๋ง๋๋ ๋ฐฉ๋ฒ์ ์ ๋ฆฌ
๐ถ ์์ ๋ฌผ์ ๋ ํ์งํ ๋ฆฌ(์ ์ฅ์)์ ์ฌ๋ฆฌ๋ 3๊ฐ์ง ๋ฐฉ๋ฒ
- ์์ ํ๋ ํด๋๋ฅผ init > git ๋ ํ์งํ ๋ฆฌ ์์ฑ > ์ฐ๊ฒฐ(remote add)
- git ๋ ํ์งํ ๋ฆฌ ์์ฑ > clone > clone ๋ฐ์ ํด๋ ์์์ ์์
- ์ ๋ํฐ ํ๋ก์ ํธ ์์ฑ > git ๋ ํฌ์งํ ๋ฆฌ ์์ฑ
๐ถ 1. ์์ ํ๋ ํด๋๋ฅผ init > git ๋ ํ์งํ ๋ฆฌ ์์ฑ > ์ฐ๊ฒฐ(remote add)
- ์์ ๊ฐ์ ํด๋์ ์์ ๋ฌผ์ด ์๋ค๊ณ ๊ฐ์
- Git Bash๋ฅผ ์ด์ด ์์ ํ๋ ํด๋๋ก ์ง์
- cd /c : c๋๋ผ์ด๋ธ๋ก ์ง์
- cd ํด๋์ด๋ฆ : ํ์ฌ ์์นํ ๊ณณ์์ ํด๋์ด๋ฆ์ ์ฐพ์์ ์ง์
- ls : ํ์ฌ ์์นํ ๊ณณ์ ์๋ ํ์ผ ๋ชฉ๋ก์ ๋ณด์ฌ์ค
- git init : ๋ก์ปฌ์ ์ฅ์ ์์ฑ
- github ํํ์ด์ง > ๋ก๊ทธ์ธ
- Your repositories
- New
- ์ ์ฅ์ ์ด๋ฆ ๊ธฐ์
- public / private : ๋จ๋ค์๊ฒ ๋ณด์ฌ์ค์ง, ๋๋ง ๋ณผ์ง ์ค์
- Add .gitignore > Unity : unity ํ๋ก์ ํธ๋ฅผ ์ฌ๋ฆด๊ฑฐ๋ผ๋ฉด ์ค์
- Code
- ์ฃผ์ ๋ณต์ฌ
- git remote add origin ์นดํผํ ์ฃผ์ : ์๊ฒฉ ์ ์ฅ์์ ์ฐ๊ฒฐ
- git remote -v : ์ฐ๊ฒฐ๋ ์๊ฒฉ ์ ์ฅ์ ํ์ธ
- git pull origin master : ์๊ฒฉ์ ์ฅ์์ master ๋ธ๋์น๋ฅผ pullํ์ฌ ๋ก์ปฌ์ master๋ธ๋์น์ ์ฐ๊ฒฐ
- git add . : ๋ชจ๋ ํ์ผ์ ์คํ ์ด์ง์ ์ฌ๋ฆผ
- git commit -m "์ปค๋ฐ๋ฉ์ธ์ง" : ์คํ ์ด์ง์ ์ฌ๋ฆฐ ํ์ผ๋ค์ ์ปค๋ฐ
- git push origin master : ์๊ฒฉ์ ์ฅ์์ master ๋ธ๋์น์ push
- ์ปค๋ฐ์ด ์ฌ๋ผ์จ ๊ฒ์ ํ์ธํ ์ ์์
๐ถ 2. git ๋ ํ์งํ ๋ฆฌ ์์ฑ > clone > clone ๋ฐ์ ํด๋ ์์์ ์์
- ์์ ๋ง๋ค์ด๋์ ์๊ฒฉ์ ์ฅ์๋ฅผ ์ด์ฉ
- ์ฃผ์ ๋ณต์ฌ
- ์๊ฒฉ ์ ์ฅ์๋ฅผ cloneํ ์์น
- git clone ์นดํผํ ์ฃผ์
- ํด๋ก ํ ์ ์ฅ์์ ์ด๋ฆ์ผ๋ก ํด๋๊ฐ ์์ฑ๋๊ณ , ๊ทธ ์๋์ ์ ์ฅ์์ ์๋ ํ์ผ๋ค์ด ์์ฑ๋ ๊ฒ์ ํ์ธ
๐ถ 3. ์ ๋ํฐ ํ๋ก์ ํธ ์์ฑ > git ๋ ํฌ์งํ ๋ฆฌ ์์ฑ
- ์ ๋ํฐ ํ๋ก์ ํธ ์์ฑ
- script ์์ฑ
- vscode๋ก ์ด๊ธฐ
- ์ฐํด๋ฆญ > New File
- ์ฃผ์ : ์ฐํด๋ฆญ ์ ํด๋ ์์ ์๋ ๊ตฌ์ญ์ด ์๋๋ผ ๋งจ ์๋์ ์๋ ๋น๊ณต๊ฐ์ ์ฐํด๋ฆญ์ ํด์ผํจ
- ํ์ผ๋ช : .gitignore
- ์ ๋๋ก ์ ๋ ฅํ๋ฉด ์ฐ์ธก ์์ด์ฝ์ด ๋ณํจ
# Created by https://www.toptal.com/developers/gitignore/api/unity
# Edit at https://www.toptal.com/developers/gitignore?templates=unity
### Unity ###
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/
# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/
# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta
# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*
# Visual Studio cache directory
.vs/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
*.apk
*.aab
*.unitypackage
# Crashlytics generated file
crashlytics-build.properties
# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
# End of https://www.toptal.com/developers/gitignore/api/unity
- .gitignore ํ์ผ์ ์์ ์ฝ๋๋ฅผ ๋ถ์ฌ๋ฃ๊ธฐ
- ์ ์ฅ
- ๋๊ฐ์ด .gitattributes ํ์ผ ์์ฑ
# Unity
*.cginc text
*.cs text diff=csharp
*.shader text
# Unity YAML
*.mat merge=unityyamlmerge eol=lf
*.anim merge=unityyamlmerge eol=lf
*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf
*.asset merge=unityyamlmerge eol=lf
*.meta merge=unityyamlmerge eol=lf
*.controller merge=unityyamlmerge eol=lf
# "physic" for 3D but "physics" for 2D
*.physicMaterial2D merge=unityyamlmerge eol=lf
*.physicMaterial merge=unityyamlmerge eol=lf
*.physicsMaterial2D merge=unityyamlmerge eol=lf
*.physicsMaterial merge=unityyamlmerge eol=lf
# Using Git LFS
# Add diff=lfs merge=lfs to the binary files
# Unity LFS
*.cubemap binary
*.unitypackage binary
# 3D models
*.3dm binary
*.3ds binary
*.blend binary
*.c4d binary
*.collada binary
*.dae binary
*.dxf binary
*.FBX binary
*.fbx binary
*.jas binary
*.lws binary
*.lxo binary
*.ma binary
*.max binary
*.mb binary
*.obj binary
*.ply binary
*.skp binary
*.stl binary
*.ztl binary
# Audio
*.aif binary
*.aiff binary
*.it binary
*.mod binary
*.mp3 binary
*.ogg binary
*.s3m binary
*.wav binary
*.xm binary
# Video
*.asf binary
*.avi binary
*.flv binary
*.mov binary
*.mp4 binary
*.mpeg binary
*.mpg binary
*.ogv binary
*.wmv binary
# Images
*.bmp binary
*.exr binary
*.gif binary
*.hdr binary
*.iff binary
*.jpeg binary
*.jpg binary
*.pict binary
*.png binary
*.psd binary
*.tga binary
*.tif binary
*.tiff binary
# Compressed Archive
*.7z binary
*.bz2 binary
*.gz binary
*.rar binary
*.tar binary
*.zip binary
# Compiled Dynamic Library
*.dll binary
*.pdb binary
*.so binary
# Fonts
*.otf binary
*.ttf binary
# Executable/Installer
*.apk binary
*.exe binary
# Documents
*.pdf binary
# ETC
*.a binary
*.rns binary
*.reason binary
# Collapse Unity-generated files on GitHub
*.asset linguist-generated
*.mat linguist-generated
*.meta linguist-generated
*.prefab linguist-generated
*.unity linguist-generated
# Spine export file for Unity
*.skel.bytes binary
- .gitattributes ํ์ผ์ ์์ ์ฝ๋ ๋ถ์ฌ๋ฃ๊ธฐ
- ์ ์ฅ
- Ctrl + Shift + P
- Publish to Github
- private / public ๊ฒฐ์
- ์ฐ์ธก ํ๋จ์ ๋จ๋ ํ์ ์ฐฝ : ๋ก๋ฉ์ด ๋๋๋ฉด ์๊ฒฉ์ ์ฅ์๊ฐ ์์ฑ๋๋ค๋ ๋ฌธ๊ตฌ๊ฐ ๋ธ
- ์ ๋ํฐํ๋ก์ ํธ๊ฐ ํฌํจ๋ ๋ ํ์งํ ๋ฆฌ๊ฐ ์์ฑ๋ ๊ฒ์ ํ์ธ
'Git' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
05. Git - add, commit, push ๊ฐ๋ (0) | 2021.09.08 |
---|---|
04. commit --amend (0) | 2021.09.06 |
Vim ๋ช ๋ น์ด - ์ต์ํ (0) | 2021.08.27 |
03. Git - Alias (0) | 2021.08.26 |
01. Git Setting (0) | 2021.08.07 |