git show
์ปค๋ฐ + ๋ณ๊ฒฝ๋ด์ฉ ํ์ธgit log
์ปค๋ฐ ๋ด์ฉ ํ์ธgit log -p
์์ธํ ๋ด์ฉgit shortlog
์ปค๋ฐ ๋ด์ฉ ๊ฐ๋ตํgit diff
์ฝ๋ ๋ด ๋ฌ๋ผ์ง ์ ๋ณด๊ธฐcat .git/config
remote ์ฃผ์๋ค ์ ์ ์์. ๋ณดํต
origin/upstream ์ด๋ฆ์ ๋ง์ด ์ฐ๋๋ฐ, upstream์ ๊ณต๋์ ์์ ๊ณต๊ฐ์ด๋ผ๋ ๋ป.
์๋ช ์ถ๊ฐ
git commit -sm ""
-s ์ต์ ์ผ๋ก ์๋ช ์ ํฌํจํ๋ค. (Signed-off by: darom)
์คํ์์ค์์ ์ค์. ๋ผ์ด์ผ์ค๋ฅผ ๋ค ์ดํดํ๊ณ ๊ฐ๋ฐ์ ํ๋ค๋ ๋ป.
commit ์์
git commit --amend
๋ด๊ฐ ๋ง์ง๋ง์ผ๋ก ํ๋ ์ปค๋ฐ ์์
--amend ํ push ํ ๋๋ ์ถฉ๋์ด ๋๋ฏ๋ก,
git push origin master --force
๋๋git push origin master -f
์ด ๋์ ์ํํ๊ธฐ ๋๋ฌธ์, ๊ณต๋์์ ์์๋ ํผํ๋ ๊ฒ ์ข๋ค.
add ๋ชฉ๋ก ์ญ์
git reset
addํ ๋ชฉ๋ก ์ญ์
touch test / rm (-f) test
commit ๋ชฉ๋ก ์ญ์
touch test
git add test; git commit -sm "test"
git push origin master
git reset HEAD~1
์ต์ ์์ผ๋ก 1๊ฐ ์ญ์ . ๊ฐ์ฅ ์ต๊ทผ ์ปค๋ฐ์ ์ง์ด๋ค. (๋ก์ปฌ์์๋ง ์ง์)
๋ฐ๋ผ์ remote ์๋ค๊ฐ๋ ํ์ฌ์ํ์ ๋๊ฐ์ด ํ๊ณ ์ถ๋ค๋ฉด, git push origin master -f
pull-request
๋ค๋ฅธ ํ๋ก์ ํธ์ ๋ด๊ฐ ๋ง๋ commit์ ์ ์ถํ๋๊ฒ์ด๋ค. (์ค์ ์ ์ก๋จ์๋ branch)
์๋๋ฐฉ ํ๋ก์ ํธ๋ฅผ fork(๋ณต์ฌ) ํด์ ๋ด ๊ณ์ ์์ ๊ด๋ฆฌ๋๋ ํ๋ก์ ํธ๋ก ์๋กญ๊ฒ ๋ง๋ค์ด ๋๊ณ ํ๋ฆฌํ๋ก ์ ์ถํ ์ ์๋ค.
remote origin ์๋ ๋ด ๋ ํฌ์ฃผ์
remote upstream ์๋ ๊ณต๋ ๋ ํฌ ์ฃผ์.
Rebase(๋๊ฐ๊ธฐ ๊ธฐ๋ฅ์ ํฌํจ)
commit์ ์ญ์ฌ์ ํ๋จ์ '๋ธ๋ญ'์ด๋ผ ํ๊ณ ๋ธ๋ญ๋ค์ ๋ชจ์์ 'tree'๋ผ ํ ๋
๋ด๊ฐ ์์ ๋ธ๋ญ์ ์ ์ ๋นผ๊ณ
โ (๋บ ๋๋จธ์ง)๊ธฐ์ค์ด ๋๋ tree๋ฅผ ์ต์ ์ ๋ฐ์ดํธ ํ ํ์
โ ๊ทธ ์์ ๋ค์ ๋ด ๋ธ๋ญ์ ์์ ์ฌ๋ฆด๋ ์ธ ์ ์๋ค.
→ ๋ฒ ์ด์ค๋ฅผ ๊ต์ฒดํ๋ค.
// remote upstream ์ถ๊ฐ. ๋ ํฌ์งํ ๋ฆฌ๋ ๊ณต์ฉ ๋ ํฌ์งํ ๋ฆฌ.
git remote add upstream http://github.com/Taeung/git-training.git
// ํ์ธ
$ cat .git/config
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = https://github.com/vo0a/git-training-1.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[remote "upstream"]
url = http://github.com/Taeung/git-training.git
fetch = +refs/heads/*:refs/remotes/upstream/*
fetch๋ก upstream์ dev ๋ธ๋์น๋ฅผ ๊ฐ์ ธ์ด
$ git fetch upstream dev
warning: redirecting to https://github.com/Taeung/git-training.git/
From http://github.com/Taeung/git-training
* branch dev -> FETCH_HEAD
* [new branch] dev -> upstream/dev
$ ls -A
.git/ img/ packing_knapsack/ pull_reqeust_test/ README.md
fetch์ pull์ ์ฐจ์ด๋ ๊ฐ์ ธ์ค๋ ๊ฒ์ ๋งคํ๊ฐ์ง๋ฐ,
- fetch๋ .git์๋ค๊ฐ ๋ฃ๊ณ
- pull์ merge๋ฅผ ๋๋ฐํ๋ค.
// ํ์ฌ ๋ด ๋ธ๋์น๊ฐ develop์ธ์ง ํ์ธ ์๋๋ผ๋ฉด ์ด๋. -> ๋ธ๋์น ์๊ด์์ด fetch๋ก ๋น๊ฒจ์จ ๊ฒ.
git status
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
$ git checkout develop
Switched to branch 'develop'
// rebase. develop์ ๋ฒ ์ด์ค๋ฅผ upstream/dev๋ก ๋ฐ๊พผ๋ค.
$ git rebase upstream/dev
First, rewinding head to replay your work on top of it...
Applying: test pull request
Applying: test // ์๋ก ์์ฑํ๋ ์ปค๋ฐ๋ค์ ๋ด์๋๋ค๊ฐ ๋ฒ ์ด์ค๊ฐ ๋ฐ๋๋ฉด ๋ค์ ์ ์ฉ๋๋ ํํ.
์ค๊ฐ์ ๋ commit ์์
์ต์ ์ปค๋ฐ์ด ์๋ ์ค๊ฐ์ ์๋ ์ปค๋ฐ์ ์์ ํ๊ณ ์ถ์ ๋ ์ฌ์ฉํ๋ค.
git rebase -i --root
// ์ต์ด์ ์ปค๋ฐ๊น์ง ๊ฐ๋๋ค.- ๋ ๋ฒ์งธ ์ปค๋ฐ์ ์์ ํด๋ณด๋ฉด,
git commit --amend
$ git rebase -i --root // ์๋ํฐ๊ฐ ๋ด์ ๋ 2๋ฒ์งธ ์ค์ ์์ ํ์.
Stopped at 864cf0f... 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
$ git shortlog
Taeung Song (2): // ๋ถ๋ช
ํ 15๊ฐ ์๋๋ฐ 2๊ฐ ๋ฐ์ ๋ณด์ด์ง ์์. -> ๋๊ฐ์๊ธฐ ๋๋ฌธ.
Add README file
Add knapsack problem PDF
/GitGitHub ์
๋ฌธ/git-training/git-training-1 (develop|REBASE-i 2/15)
$ git status
interactive rebase in progress; onto cf2a256
Last commands done (2 commands done):
pick 73e7acf Add README file
edit 864cf0f Add knapsack problem PDF
Next commands to do (13 remaining commands):
pick f9b87bb packing knapsack: Basic code solving this question
pick 91f2d24 packing knapsack: Change basic code
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch 'develop' on 'cf2a256'.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)
nothing to commit, working tree clean
- ๋ง์น ์์ ์ญ์ฌ๋ก ๋์๊ฐ ๊ฒ์ฒ๋ผ,
- ๊ทผ๋ฐ statusํด๋ณด๋ฉด ์ ๊น ๋๊ฐ์ ๋์๋ค๋ ๊ฒ์ ์ ์ ์๋ค.
- 2๋ฒ์งธ ์ปค๋ฐ๊น์ง.
- ๊ทธ๋ฌ๋ฉด, ์ด์ --amend๋ฅผ ํตํด ์์ ํ ์ ์๊ฒ ๋๋ค.
// ๋ ๋ฒ์งธ ์ปค๋ฐ ๋ฉ์์ง ์์
$ git commit --amend -sm "packing knapsack: Add knapsack problem PDF"
[detached HEAD 24f7c1f] packing knapsack: Add knapsack problem PDF
Author: Taeung Song <treeze.taeung@gmail.com>
Date: Fri Mar 25 12:00:37 2016 +0900
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 packing_knapsack/knapsack_problem.pdf
// ๋ณ๊ฒฝ๋ ์ปค๋ฐ ๋ฉ์์ง ํ์ธ
$ git shortlog
Taeung Song (2):
Add README file
packing knapsack: Add knapsack problem PDF
// rebase๋ฅผ ๊ณ์ํ๋ฉด ๊ฐ์๋จ๋ ๊ฒ์ ์ญ ํธ๋ ๊ฒ์ด๋ค.
$ git rebase --continue
Successfully rebased and updated refs/heads/develop.
// ๋ด์ญ์ ๋ชจ๋ ํ์ธํ ์ ์๋ค.
$ git shortlog
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
vo0a (2):
test pull request
test
- rebase -i(-interactive) ๋ฅผ ๋ฌถ์ด์ ํ๋์ ์๋ธ ์ปค๋ฉ๋๋ฅผ ๋ง๋ ๋ค๊ณ ํ๋ค๋ฉด rewind ๋ฅผ ์ธ ๊ฒ ๊ฐ๋ค. -> ๋๊ฐ๋ ๊ฒ์ด ํฌ์ธํธ.
Blame
$ cd report-card
$ git blame report_card.c
7161cacd (vo0a 2020-04-06 23:16:45 +0900 1) #include<stdio.h>
7161cacd (vo0a 2020-04-06 23:16:45 +0900 2)
7161cacd (vo0a 2020-04-06 23:16:45 +0900 3) int main()
7161cacd (vo0a 2020-04-06 23:16:45 +0900 4) {
badb0fab (vo0a 2020-04-06 23:22:19 +0900 5) int kor, eng, math;
198fa683 (vo0a 2020-04-06 23:24:44 +0900 6) int sum = 0;
badb0fab (vo0a 2020-04-06 23:22:19 +0900 7)
badb0fab (vo0a 2020-04-06 23:22:19 +0900 8) math = 80;
badb0fab (vo0a 2020-04-06 23:22:19 +0900 9) eng = 100;
badb0fab (vo0a 2020-04-06 23:22:19 +0900 10) kor = 90;
198fa683 (vo0a 2020-04-06 23:24:44 +0900 11) sum = 80 + 100 + 90;
badb0fab (vo0a 2020-04-06 23:22:19 +0900 12)
0e5cc18f (vo0a 2020-04-06 23:20:24 +0900 13) printf("This program print report card.\n");
badb0fab (vo0a 2020-04-06 23:22:19 +0900 14)
badb0fab (vo0a 2020-04-06 23:22:19 +0900 15) printf("Korean : %d\n", kor);
badb0fab (vo0a 2020-04-06 23:22:19 +0900 16) printf("English : %d\n", eng);
badb0fab (vo0a 2020-04-06 23:22:19 +0900 17) printf("Math : %d\n", math);
198fa683 (vo0a 2020-04-06 23:24:44 +0900 18) printf("Sum : %d\n", sum);
68d507ec (vo0a 2020-04-06 23:30:35 +0900 19) printf("Average : %d\n", sum/3);
7161cacd (vo0a 2020-04-06 23:16:45 +0900 20) return 0;
7161cacd (vo0a 2020-04-06 23:16:45 +0900 21) }
- ์์ค์ฝ๋ ๋ด์ฉ๊ณผ ๋ผ์ธ๋๋ฒ๊ฐ ๊ทธ๋๋ก ๋์จ๋ค.
- ํด๋น ๋ผ์ธ์ด ์ด๋ค ์ปค๋ฐ๊ณผ ์ฐ๊ด๋์ด์๋์ง ์ ์ ์๋ค.
git show 68d507ec
๋ก ํด๋น ์ปค๋ฐ ๋ด์ฉ์ ํ์ธํ ์๋ ์๋ค.
์๋์ฐธ์กฐ
์๋ ์ฐธ์กฐ๋ก ์ฐ๋ฆฌ๊ฐ ๊ธฐ์ตํ ๋งํ ์ง์ (๋ธ๋์น bugFix๋ผ๋๊ฐ HEAD๋ผ๋๊ฐ)์์ ์ถ๋ฐํด์ ์ด๋ํ์ฌ ๋ค๋ฅธ ์ง์ ์ ๋๋ฌํด ์์ ์ ํ ์ ์๋ค.
- ํ๋ฒ์ ํ ์ปค๋ฐ ์๋ก ์์ง์ด๋ ^
- ํ๋ฒ์ ์ฌ๋ฌ ์ปค๋ฐ ์๋ก ์ฌ๋ผ๊ฐ๋ ~<num>
'๐ > GIT' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Git] ๋ด๊ฐ ๋ณด๊ธฐ ์ํด ์ ๋ฆฌํ๋ Git (0) | 2019.08.09 |
---|
๋๊ธ