본문 바로가기
  • 경제적 자유를 얻는 그날까지
엔지니어링/프로그래밍

[프로그래밍 일반] GIT 사용법 및 팁

by 베니스상인 2021. 8. 18.

 

 

버전 관리가 필요한 이유?

  • 지난 과정을 확인 가능
  • 수정한 현재코드에 문제가 생길 경우 이전 버전으로 돌아갈 수 있음

 

 Git 사용의 필요성

  • 버전관리
  • 협업
  • 다른 컴퓨터에 작업물을 보내기(github)

 

 

Git의 구성요소

1. Repository

  • 저장소, commit이 저장되는 공간
  • .git 디렉토리
  • 프로젝트의 초창기 부터 버전별 스냅샷 및 설명이 있음
  •  

2. commit

  • 프로젝트 디렉토리의 현재의 모습의 하나의 버전으로 만드는 행위와 결과물

 

 

Git을 이용한 프로젝트 관리

 

1) git init

  • 현재 디렉토리를  git repository로 생성하고, git 설정을 초기화함
  • .git이 생성됨

 

2) git config

  • commit 하기전 사용자의 이름과 메일을  git에게 알려주어야 함

 

3) git add

  • commit 이전에 git에서  관리(track)할 대상 파일을 지정하는 행위

 

4) git commit

  • commit은 하나의 버전으로 기록하는 행위
  • commit을 하기 전에 관리할 파일들이 지정되어야 하고(staging area에 올라가야 함) 사용자의 이름, 이메일과 commit메시지를 남겨주어야 함
  • 아래 로그에서 root-commit은 첫번째 commit이라는 의미, 그리고 옆에는 commit시 작성한 설명이 보임, 총 2개의 파일이 변경되었고, 그 2개는 새로 등록되었음 의미, 총 8개의 소스코드 라인이 추가되었음 확인

 

Swift@Swift:~/workspace/study/git$ cd MathTool/
swift@Swift:~/workspace/study/git/MathTool$ ll
total 16
drwxrwxr-x 2 swift swift 4096 10월 14 04:01 ./
drwxrwxr-x 3 swift swift 4096 10월 14 04:01 ../
-rw-rw-r-- 1 swift swift   66 10월 14 04:01 calculator.py
-rw-rw-r-- 1 swift swift    5 10월 14 04:01 License
swift@Swift:~/workspace/study/git/MathTool$ git init
Initialized empty Git repository in /home/swift/workspace/study/git/MathTool/.git/

swift@Swift:~/workspace/study/git/MathTool$ git config user.name "shlee853"

swift@Swift:~/workspace/study/git/MathTool$ git config user.email "seunghyun.lee853@gmail.com"

swift@Swift:~/workspace/study/git/MathTool$ git add calculator.py 

swift@Swift:~/workspace/study/git/MathTool$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
	new file:   calculator.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	License

swift@Swift:~/workspace/study/git/MathTool$ git add .
swift@Swift:~/workspace/study/git/MathTool$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
	new file:   License
	new file:   calculator.py

swift@Swift:~/workspace/study/git/MathTool$ git commit -m "Initial Release"
[master (root-commit) 3644443] Initial Release
 2 files changed, 8 insertions(+)
 create mode 100644 License
 create mode 100644 calculator.py

 

 

 

 

 

 

일부 파일을 수정할 경우 commit의 결과

swift@Swift:~/workspace/study/git/MathTool$ vim calculator.py 

swift@Swift:~/workspace/study/git/MathTool$ vim License 

swift@Swift:~/workspace/study/git/MathTool$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   License
	modified:   calculator.py

no changes added to commit (use "git add" and/or "git commit -a")

swift@Swift:~/workspace/study/git/MathTool$ git add calculator.py 

swift@Swift:~/workspace/study/git/MathTool$ git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	modified:   calculator.py

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   License

swift@Swift:~/workspace/study/git/MathTool$ git commit -m "Add comments on calcuator.py"
[master 2cbe6db] Add comments on calcuator.py
 1 file changed, 1 insertion(+)

 

 

 

 

 

 

 

 

GitHub 사용하기

 

1) github.com에서 자신의 계정을 등록하고 접속하기

2) 새로운 remote repository  만들기

3) repository에서 제공한 주소로 push 하기

 

이미 local respository가 있는 경우 두번째 방법으로 add  및 push만 하면됨

swift@Swift:~/workspace/study/git/MathTool$ git remote add origin https://github.com/shlee853/Math_box.git

swift@Swift:~/workspace/study/git/MathTool$ git branch -M main

swift@Swift:~/workspace/study/git/MathTool$ git push -u origin main
Username for 'https://github.com': shlee853
Password for 'https://shlee853@github.com': 
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 12 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (7/7), 609 bytes | 304.00 KiB/s, done.
Total 7 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/shlee853/Math_box.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
swift@Swift:~/workspace/study/git/MathTool$

 

 

push에서 인증방법이 패스워드에서 토큰방식으로 변경되었으므로 토큰을 발급받아서 입력해야 함. 토큰 발급방법은 아래 게시글 참고하면 됨

 

https://dev.classmethod.jp/articles/resolving-github-token-authentication-errors/

 

GitHub 토큰 인증 에러 해결 remote: Support for password authentication was removed. Please use a personal access token i

git push 명령어를 입력할 때 나오는 토큰 인증 에러를 해결하는 방법에 대해서 정리해 봤습니다.

dev.classmethod.jp

 

 

remote repository에 정상적으로 업로드된 것을 확인할 수 있음

 

 

Local Repo에서 수정된 사항을 Remote Repo에 반영하기

 

swift@Swift:~/workspace/study/git/MathTool$ git add README.md 

swift@Swift:~/workspace/study/git/MathTool$ git commit -m "Add README.md file"
[main f93e6a7] Add README.md file
 1 file changed, 2 insertions(+)
 create mode 100644 README.md

swift@Swift:~/workspace/study/git/MathTool$ git push
Username for 'https://github.com': shlee853
Password for 'https://shlee853@github.com': 
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 363 bytes | 363.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/shlee853/Math_box.git
   2cbe6db..f93e6a7  main -> main

 

 

 

Remote Repo에서 수정된 사항을 Local Repo에 반영하기

 

swift@Swift:~/workspace/study/git/MathTool$ git pull
Username for 'https://github.com': shlee853
Password for 'https://shlee853@github.com': 
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 806 bytes | 403.00 KiB/s, done.
From https://github.com/shlee853/Math_box
   f93e6a7..0dab79a  main       -> origin/main
Updating f93e6a7..0dab79a
Fast-forward
 README.md | 1 +
 1 file changed, 1 insertion(+)

 

 

 

git log 확인하기

  • log 내용중 -는 이전 커밋, +는 현재 커밋으로 변경된 부분
swift@Swift:~/workspace/study/git/MathTool$ git log
commit 0dab79a77b958c4878285a5fb3fc6279742416ad (HEAD -> main, origin/main)
Author: shlee853 <seunghyun.lee853@gmail.com>
Date:   Fri Oct 14 05:03:42 2022 +0900

    Add info of calculator.py in README.md file

commit f93e6a7a612d9c172dc1efe118861c009e60fcd7
Author: shlee853 <seunghyun.lee853@gmail.com>
Date:   Fri Oct 14 04:57:00 2022 +0900

    Add README.md file

commit 2cbe6db44d5435e696bd6c61fd6d4749ba2570e3
Author: shlee853 <seunghyun.lee853@gmail.com>
Date:   Fri Oct 14 04:28:27 2022 +0900

    Add comments on calcuator.py

commit 3644443da9d2d3cec8aa724275c562cc00da4756
Author: shlee853 <seunghyun.lee853@gmail.com>
Date:   Fri Oct 14 04:12:11 2022 +0900

    Initial Release
    
    
    
swift@Swift:~/workspace/study/git/MathTool$ git log --pretty=oneline
0dab79a77b958c4878285a5fb3fc6279742416ad (HEAD -> main, origin/main) Add info of calculator.py in README.md file
f93e6a7a612d9c172dc1efe118861c009e60fcd7 Add README.md file
2cbe6db44d5435e696bd6c61fd6d4749ba2570e3 Add comments on calcuator.py
3644443da9d2d3cec8aa724275c562cc00da4756 Initial Release


swift@Swift:~/workspace/study/git/MathTool$ git show 2cbe
commit 2cbe6db44d5435e696bd6c61fd6d4749ba2570e3
Author: shlee853 <seunghyun.lee853@gmail.com>
Date:   Fri Oct 14 04:28:27 2022 +0900

    Add comments on calcuator.py

diff --git a/calculator.py b/calculator.py
index be4d4e8..3bf45f4 100644
--- a/calculator.py
+++ b/calculator.py
@@ -1,3 +1,4 @@
+# 파이썬 수학연산 함수
 def add(a,b):
     return a+b

 

 

 

git commit --amend

  • 최신 커밋을 수정할 수 있음, 수정하고 나면 해시태그가 변경됨
swift@Swift:~/workspace/study/git/MathTool$ git config user.name 'shlee853'
swift@Swift:~/workspace/study/git/MathTool$ git config user.email 'seunghyun.lee853@gmail.com'

swift@Swift:~/workspace/study/git/MathTool$ vim calculator.py 

swift@Swift:~/workspace/study/git/MathTool$ git add .

swift@Swift:~/workspace/study/git/MathTool$ git commit
[main 4b8fd19] Add one function calculator.py supports 3 functions
 2 files changed, 3 insertions(+), 1 deletion(-)

swift@Swift:~/workspace/study/git/MathTool$ git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

swift@Swift:~/workspace/study/git/MathTool$ git log --pretty=oneline
4b8fd1938d2a4298f2c8386a156f4be28f500c3b (HEAD -> main) Add one function calculator.py supports 3 functions
0dab79a77b958c4878285a5fb3fc6279742416ad (origin/main) Add info of calculator.py in README.md file
f93e6a7a612d9c172dc1efe118861c009e60fcd7 Add README.md file
2cbe6db44d5435e696bd6c61fd6d4749ba2570e3 Add comments on calcuator.py
3644443da9d2d3cec8aa724275c562cc00da4756 Initial Release

swift@Swift:~/workspace/study/git/MathTool$ vim calculator.py 

swift@Swift:~/workspace/study/git/MathTool$ git commit --amend
[main 150e81f] Add one function multiply calculator.py supports 3 functions
 Date: Sat Oct 15 06:44:13 2022 +0900
 2 files changed, 3 insertions(+), 1 deletion(-)

swift@Swift:~/workspace/study/git/MathTool$ git log --pretty=oneline
150e81f034baab66b60741f7ff90c6afbd741bc0 (HEAD -> main) Add one function multiply calculator.py supports 3 functions
0dab79a77b958c4878285a5fb3fc6279742416ad (origin/main) Add info of calculator.py in README.md file
f93e6a7a612d9c172dc1efe118861c009e60fcd7 Add README.md file
2cbe6db44d5435e696bd6c61fd6d4749ba2570e3 Add comments on calcuator.py
3644443da9d2d3cec8aa724275c562cc00da4756 Initial Release

 

 

 

Local repo와 Remote repo 가 버전이 다를경우 git pull로 repote  repo를 내려받아 merge하는 것임, merge 후 Head(local)와 main(remote)이 동일한 해시태그에 있다는 것은 local과 remote가 동일하다는 의미임

 

swift@Swift:~/workspace/study/git/MathTool$ git push
Username for 'https://github.com': shlee853
Password for 'https://shlee853@github.com': 
To https://github.com/shlee853/Math_box.git
 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'https://github.com/shlee853/Math_box.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

swift@Swift:~/workspace/study/git/MathTool$ git pull
Username for 'https://github.com': shlee853
Password for 'https://shlee853@github.com': 
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 807 bytes | 807.00 KiB/s, done.
From https://github.com/shlee853/Math_box
   0dab79a..0d70eb5  main       -> origin/main
Merge made by the 'recursive' strategy.
 README.md | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

swift@Swift:~/workspace/study/git/MathTool$ git log --pretty=oneline
9d2c5f0d1a5e05a6482ef3b02aaa8e071bb2525c (HEAD -> main) Merge branch 'main' of https://github.com/shlee853/Math_box into main
150e81f034baab66b60741f7ff90c6afbd741bc0 Add one function multiply calculator.py supports 3 functions
0d70eb5bb3c27519ab4c9cc85ec45a0ae9351928 (origin/main) Update README.md
0dab79a77b958c4878285a5fb3fc6279742416ad Add info of calculator.py in README.md file
f93e6a7a612d9c172dc1efe118861c009e60fcd7 Add README.md file
2cbe6db44d5435e696bd6c61fd6d4749ba2570e3 Add comments on calcuator.py
3644443da9d2d3cec8aa724275c562cc00da4756 Initial Release

swift@Swift:~/workspace/study/git/MathTool$ git add.
git: 'add.' is not a git command. See 'git --help'.

The most similar command is
	add
swift@Swift:~/workspace/study/git/MathTool$ git add .
swift@Swift:~/workspace/study/git/MathTool$ git commit
[main 8591195] Merged remote repo and local repo
 1 file changed, 3 insertions(+)

swift@Swift:~/workspace/study/git/MathTool$ git push
Username for 'https://github.com': shlee853
Password for 'https://shlee853@github.com': 
Enumerating objects: 15, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 12 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (9/9), 1005 bytes | 1005.00 KiB/s, done.
Total 9 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 1 local object.
To https://github.com/shlee853/Math_box.git
   0d70eb5..8591195  main -> main

swift@Swift:~/workspace/study/git/MathTool$ git log --pretty=oneline
859119528fc67d40b6588dcdad568febfc861868 (HEAD -> main, origin/main) Merged remote repo and local repo
9d2c5f0d1a5e05a6482ef3b02aaa8e071bb2525c Merge branch 'main' of https://github.com/shlee853/Math_box into main
150e81f034baab66b60741f7ff90c6afbd741bc0 Add one function multiply calculator.py supports 3 functions
0d70eb5bb3c27519ab4c9cc85ec45a0ae9351928 Update README.md
0dab79a77b958c4878285a5fb3fc6279742416ad Add info of calculator.py in README.md file
f93e6a7a612d9c172dc1efe118861c009e60fcd7 Add README.md file
2cbe6db44d5435e696bd6c61fd6d4749ba2570e3 Add comments on calcuator.py
3644443da9d2d3cec8aa724275c562cc00da4756 Initial Release

 

 

 

git의 alias 기능

  • git에서 alias 기능을 아래와 같이 config 명령을 이용하여 만들 수 있음
swift@Swift:~/workspace/study/git/MathTool$ git config alias.history 'log --pretty=oneline'

swift@Swift:~/workspace/study/git/MathTool$ git history
859119528fc67d40b6588dcdad568febfc861868 (HEAD -> main, origin/main) Merged remote repo and local repo
9d2c5f0d1a5e05a6482ef3b02aaa8e071bb2525c Merge branch 'main' of https://github.com/shlee853/Math_box into main
150e81f034baab66b60741f7ff90c6afbd741bc0 Add one function multiply calculator.py supports 3 functions
0d70eb5bb3c27519ab4c9cc85ec45a0ae9351928 Update README.md
0dab79a77b958c4878285a5fb3fc6279742416ad Add info of calculator.py in README.md file
f93e6a7a612d9c172dc1efe118861c009e60fcd7 Add README.md file
2cbe6db44d5435e696bd6c61fd6d4749ba2570e3 Add comments on calcuator.py
3644443da9d2d3cec8aa724275c562cc00da4756 Initial Release

 

 

git diff를 이용하여 두 커밋사이의 변화 알아보기

859119528fc67d40b6588dcdad568febfc861868 (HEAD -> main, origin/main) Merged remote repo and local repo
9d2c5f0d1a5e05a6482ef3b02aaa8e071bb2525c Merge branch 'main' of https://github.com/shlee853/Math_box into main
150e81f034baab66b60741f7ff90c6afbd741bc0 Add one function multiply calculator.py supports 3 functions
0d70eb5bb3c27519ab4c9cc85ec45a0ae9351928 Update README.md
0dab79a77b958c4878285a5fb3fc6279742416ad Add info of calculator.py in README.md file
f93e6a7a612d9c172dc1efe118861c009e60fcd7 Add README.md file
2cbe6db44d5435e696bd6c61fd6d4749ba2570e3 Add comments on calcuator.py
3644443da9d2d3cec8aa724275c562cc00da4756 Initial Release

swift@Swift:~/workspace/study/git/MathTool$ git diff f93e 0d70
diff --git a/README.md b/README.md
index 7a4f229..1ad2bab 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,4 @@
-### 수학계산을 위한 코드
+# 수학계산을 위한 코드
 
+**1. Calculator.py** : 계산기에 있는 기능들을 제공하는 모듈
+- add, subtract등

 

 

git reset

  • 커밋의 내용을 과거로 돌리고 싶을 때 사용
  • HEAD 가 현재 커밋에서 reset에 의해 지정된 커밋으로 가리키고 working directory 내용도 과거 내용으로 회귀됨

 

 

 

 

 

 

 

 

 

 

 

 

Git Command 정리

  • git init : 현재 디렉토리를 Git이 관리하는 프로젝트 디렉토리(=working directory)로 설정하고 그 안에 레포지토리(.git 디렉토리) 생성
  • git config user.name 'shlee853' : 현재 사용자의 아이디를 'codeit'으로 설정(커밋할 때 필요한 정보)
  • git config user.email 'seunghyun.lee853@gmail.com' : 현재 사용자의 이메일 주소를 'awunghyun.lee853@gmail.com'로 설정(커밋할 때 필요한 정보)
  • 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에 있는 프로젝트를 내 컴퓨터로 가져오기
  • git log : 커밋 히스토리를 출력
  • git log --pretty=oneline : --pretty 옵션을 사용하면 커밋 히스토리를 다양한 방식으로 출력할 수 있습니다. --pretty 옵션에 oneline이라는 값을 주면 커밋 하나당 한 줄씩 출력해줍니다. --pretty 옵션에 대해 더 자세히 알고싶으면 이 링크를 참고하세요. 
  • git show [커밋 아이디] : 특정 커밋에서 어떤 변경사항이 있었는지 확인
  • git commit --amend : 최신 커밋을 다시 수정해서 새로운 커밋으로 만듦
  • git config alias.[별명] [커맨드] : 길이가 긴 커맨드에 별명을 붙여서 이후로는 별명으로도 해당 커맨드를 실행할 수 있게 설정
  • git diff [커밋 A의 아이디] [커밋 B의 아이디] : 두 커밋 간의 차이 비교
  • git reset [옵션] [커밋 아이디] : 옵션에 따라 하는 작업이 달라짐(옵션을 생략하면 --mixed 옵션이 적용됨) 

       - HEAD가 특정 커밋을 가리키도록 이동시킴(--soft는 여기까지 수행)

       - staging area도 특정 커밋처럼 리셋(--mixed는 여기까지 수행)

       - working directory도 특정 커밋처럼 리셋(--hard는 여기까지 수행)

       그리고 이때 커밋 아이디 대신 HEAD의 위치를 기준으로 한 표기법(예 : HEAD^, HEAD~3)을 사용해도 됨

  • git tag [태그 이름] [커밋 아이디] : 특정 커밋에 태그를 붙임
  • git branch [새 브랜치 이름] : 새로운 브랜치를 생성
  • git checkout -b [새 브랜치 이름] : 새로운 브랜치를 생성하고 그 브랜치로 바로 이동
  • git branch -d [기존 브랜치 이름] : 브랜치 삭제
  • git checkout [기존 브랜치 이름] : 그 브랜치로 이동
  • git merge [기존 브랜치 이름] : 현재 브랜치에 다른 브랜치를 머지
  • git merge --abort : 머지를 하다가 conflict가 발생했을 때, 일단은 머지 작업을 취소하고 이전 상태로 돌아감
  • git fetch : 로컬 레포지토리에서 현재 HEAD가 가리키는 브랜치의 업스트림(upstream) 브랜치로부터 최신 커밋들을 가져옴(가져오기만 한다는 점에서, 가져와서 머지까지 하는 git pull과는 차이가 있음)
  • git blame : 특정 파일의 내용 한줄한줄이 어떤 커밋에 의해 생긴 것인지 출력 
  • git revert : 특정 커밋에서 이루어진 작업을 되돌리는(취소하는) 커밋을 새로 생성
  • git reflog : HEAD가 그동안 가리켜왔던 커밋들의 기록을 출력
  • git log --all --graph : 모든 브랜치의 커밋 히스토리를, 커밋 간의 관계가 잘 드러나도록 그래프 형식으로 출력
  • git rebase [브랜치 이름] : A, B 브랜치가 있는 상태에서 지금 HEAD가 A 브랜치를 가리킬 때, git rebase B를 실행하면 A, B 브랜치가 분기하는 시작점이 된 공통 커밋 이후로부터 존재하는 A 브랜치 상의 커밋들이 그대로 B 브랜치의 최신 커밋 이후로 이어붙여짐(git merge와 같은 효과를 가지지만 커밋 히스토리가 한 줄로 깔끔하게 된다는 차이점이 있음)
  • git stash : 현재 작업 내용을 스택 영역에 저장
  • git stash apply [커밋 아이디] : 스택 영역에 저장된 가장 최근의(혹은 특정) 작업 내용을 working directory에 적용
  • git stash drop [커밋 아이디] : 스택 영역에 저장된 가장 최근의(혹은 특정) 작업 내용을 스택에서 삭제
  • git stash pop [커밋 아이디] : 스택 영역에 저장된 가장 최근의(혹은 특정) 작업 내용을 working directory에 적용하면서 스택에서 삭제
  • git cherry-pick [커밋 아이디] : 특정 커밋의 내용을 현재 커밋에 반영



 

 

 

 

 

 

본 강의 내용은 아래 강의를 참고하여 작성한 내용입니다.

 

https://www.codeit.kr/topics/git?pathType=CAREER&pathSlug=data-scientist 

 

Git - GIT 강의 | 코드잇

개발자라면 Git 사용 능력은 필수인 시대가 되었습니다! 대부분의 소프트웨어는 많은 개발자들이 오랜 시간 협업을 통해 만든 결과물인데요. 다른 개발자와 코드를 공유하고, 프로젝트의 버전을

www.codeit.kr

 

728x90

댓글