-
커밋메시지 다루기 (m옵션 없이 메세지 남기기, 최신 커밋 수정하기, as로 별칭 만들기, 두 커밋 간의 차이보기)Git 2023. 2. 19. 10:12
calculator.py 수정하기
calculator.py
# 기본계산기 def add(a,b): return a + b def subtract(a,b): return a - b def multiply(a,b): return a + b
git add .
git commit
i를 눌러서 편집모드로 간다
저장은 ESC + :wq!git log에서 확인해보기
commit aaf39bfb5bccf75a27daaee533070234bab08501 (HEAD -> master) Author: yunajoe <yunajoe@gmail.com> Date: Sat Feb 18 20:02:32 2023 +0900 Add one function calculator.py supports 3 functions now : commit 23453a29860fb3bce2a87749717bfd6f1dfc0100 (origin/master) Author: yunajoe <86518113+yunajoe@users.noreply.github.com> Date: Sat Feb 18 18:19:35 2023 +0900 Add the info in README.md commit 74b3b85cae59f4dc2daaee15110fc7724a1812a1 Author: yunajoe <yunajoe@gmail.com> Date: Sat Feb 18 17:19:29 2023 +0900 readme수정
최신 커밋 수정하기(가장 최신 커밋을 수정해서 다시 새로운 커밋으로 만들 수 있다)
git commit --amend
커밋할 .py을 수정해야 한다
calculator.py
def add(a,b): return a + b def subtract(a,b): return a - b // 요 부분 수정 def multiply(a,b): return a * b
$ git add . $ git commit --amend $ git push fatal: credential-cache unavailable; no unix socket support Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 12 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 364 bytes | 364.00 KiB/s, done. Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (1/1), completed with 1 local object. To https://github.com/yunajoe/Git_Practice.git 23453a2..75494b3 master -> master
긴 커맨드에 alias 설정하기
Git에서 커맨드와 옵션을 타이핑할 때 너무 길이가 길면 힘들 때가 있습니다.
이럴 때는 그냥 전체 커맨드를 좀더 짧은 길이의 별명으로 가리킬 수 있도록
설정가장 최신 커밋을 수정해서 다시 새로운 커밋으로 만들 수 있는 기회git config alias.[새로운 별명] [길이가 긴 커맨드]
예를 들어 git log --pretty=oneline 이라는 커맨드가 너무 길어서 치기 힘들 때 'log --pretty=oneline' 이 부분을 좀더 짧은 별명으로 지칭할 수 있도록 설정할 수 있습니다. 'log --pretty=oneline'에 history라는 별명
$ git config alias.history 'log --pretty=oneline'
git histroy라고만 써도 자동으로 git log --pretty=oneline을 실행하게 됩니다.
--------------------------------
두 커밋 간의 차이보기(변화보기)
git diff [커밋 A의 아이디] [커밋 B의 아이디]
$ git diff 09534 23453 diff --git a/README.md b/README.md index 454778d..20a869d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -## Git Bash 연습입니당 -**1. calculator.py** => 계산기 모듈 +## Git Bash 연습 Repo입니다 +**1. calculator.py** => 계산기의 기능들을 제공하는 모듈
'Git' 카테고리의 다른 글
브랜치 시작하기 (0) 2023.02.19 git reset (0) 2023.02.19 커밋 히스토리 (0) 2023.02.19 오픈소스(Open Source) & Glt Clone해보기 (0) 2022.09.22 Remote repository와 Local repository를 연결해보기 (0) 2022.09.17