메모장 입니다2

공개SW] Git - day 4 본문

Study/Programming

공개SW] Git - day 4

Wooum@n 2019. 7. 26. 22:39

1.git blame [파일명]  : 해당 파일의 변경기록을 확인할 수 있음

 

root@goorm:/work/git/report-card(master)# git blame report_card.c
dc0304ed (woounnan 2019-07-18 14:47:42 +0000  1) #include
dc0304ed (woounnan 2019-07-18 14:47:42 +0000  2)
dc0304ed (woounnan 2019-07-18 14:47:42 +0000  3) int main()
dc0304ed (woounnan 2019-07-18 14:47:42 +0000  4) {
2c95666b (woounnan 2019-07-19 13:21:25 +0000  5)        int kor, eng, math;
2c95666b (woounnan 2019-07-19 13:21:25 +0000  6)        int sum = 0;
2c95666b (woounnan 2019-07-19 13:21:25 +0000  7)
2c95666b (woounnan 2019-07-19 13:21:25 +0000  8)        math = 80;
2c95666b (woounnan 2019-07-19 13:21:25 +0000  9)        eng = 100;
2c95666b (woounnan 2019-07-19 13:21:25 +0000 10)        kor = 90;
2c95666b (woounnan 2019-07-19 13:21:25 +0000 11)        sum = 80 + 100 + 90;
2c95666b (woounnan 2019-07-19 13:21:25 +0000 12)
44ddbe9d (woounnan 2019-07-19 13:14:52 +0000 13)        printf("This program print report card.\n");
2c95666b (woounnan 2019-07-19 13:21:25 +0000 14)
2c95666b (woounnan 2019-07-19 13:21:25 +0000 15)        printf("Korean : %d\n", kor);
2c95666b (woounnan 2019-07-19 13:21:25 +0000 16)        printf("English : %d\n", eng);
2c95666b (woounnan 2019-07-19 13:21:25 +0000 17)        printf("Math : %d\n", math);
2c95666b (woounnan 2019-07-19 13:21:25 +0000 18)        printf("Sum : %d\n", sum);
2c95666b (woounnan 2019-07-19 13:21:25 +0000 19)        printf("Average : %d\n", sum/3);
dc0304ed (woounnan 2019-07-18 14:47:42 +0000 20)        return 0;
dc0304ed (woounnan 2019-07-18 14:47:42 +0000 21) }


root@goorm:/work/git/report-card(master)# git show dc0304ed  //blame에서 확인하고 싶은 commit을 자세히 출력
commit dc0304edeec330072e6c61db8a3c2b57b9aa801a
Author: woounnan <woounnan@gmail.com>
Date:   Thu Jul 18 14:47:42 2019 +0000

    report card: Add a source file about new pdf file

diff --git a/report_card.c b/report_card.c
new file mode 100644
index 0000000..e3206d2
--- /dev/null
+++ b/report_card.c
@@ -0,0 +1,6 @@
+#include
+
+int main()
+{
+       return 0;
+}
root@goorm:/work/git/report-card(master)#

 

 

 

2.git rebase [옵션]  : 특정 시점으로 되돌리기

 

root@goorm:/work/git/git-training(develop)# git rebase -i --root //입력시 commit log가 출력된다.

출력된 commit log

변경하고 싶은 commit의 "pick"을 "edit"로 수정 후 빠져나오기

Stopped at 864cf0fdaaa053cca67b9782105cc7db7496c177... Add knapsack problem PDF
You can amend the commit now, with

        git commit --amend

Once you are satisfied with your changes, run

        git rebase --continue

 

root@goorm:/work/git/git-training((브랜치 없음, develop 리베이스))# git shortlog  //상태 확인
Taeung Song (2):
      Add README file
      Add knapsack problem PDF  
//commit이 내가 돌린 시점으로 변경되었다
root@goorm:/work/git/git-training((브랜치 없음, develop 리베이스))# git status
rebase in progress; onto ef6464a
You are currently editing a commit while rebasing branch 'develop' on 'ef6464a'.
  (use "git commit --amend" to amend the current commit)
  (use "git rebase --continue" once you are satisfied with your changes)

nothing to commit, working directory clean
root@goorm:/work/git/git-training((브랜치 없음, develop 리베이스))# ls
README.md  img  packing_knapsack

 

 

root@goorm:/work/git/git-training((브랜치 없음, develop 리베이스))# git commit --amend -sm "packing knapsack: Add knapsa  

//파일 등을 수정한 뒤, commit을 새롭게 입력  

--amend는 가장 최근의 commit을 수정해주는 옵션 *


ck problem PDF"
[detached HEAD 107d5c4] packing knapsack: Add knapsack problem PDF
 Author: Taeung Song <treeze.taeung@gmail.com>
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 packing_knapsack/knapsack_problem.pdf

 

 

root@goorm:/work/git/git-training((브랜치 없음, develop 리베이스))# git rebase --continue

//현재 상태를 저장한 상태로 rebase한 것을 복구시킴

Successfully rebased and updated refs/heads/develop.
root@goorm:/work/git/git-training(develop)# git shortlog //확인해보면, 해당 commit이 변경되었다.
Taeung Song (13): 
      Add README file
      packing knapsack: Add knapsack problem PDF
      packing knapsack: Basic code solving this question
      packing knapsack: Change basic code
      packing knapsack: Rename packing_knapsack to pack_knapsack
      packing knapsack: Input & Output
      packing knapsack: Add test script
      packing knapsack: Add test script generator
      packing knapsack: Implement code to solve this question
      test git-pull-request
      New version git-training
      Add v3 PDF
      Rebase test

woounnan (2):
      test pull request
      this is branch of test

root@goorm:/work/git/git-training(develop)#

'Study > Programming' 카테고리의 다른 글

공개SW] Web - day 2  (0) 2019.08.03
공개SW] Web - day 1  (0) 2019.07.31
공개SW] Git - day 3  (0) 2019.07.23
Python] 문자열 헥스값 "\x" 형식으로 변경  (0) 2019.07.21
공개SW] Git - day 2  (0) 2019.07.19