uncategorized

git squash

date: 2018-12-02 20:26:59

์ค€๋น„

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 jake.ko ๎‚ฐ ~/Dev ๎‚ฐ cd git-study
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ll
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ git init
Initialized empty Git repository in /Users/jake.ko/Dev/git-study/.git/
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master ๎‚ฐ ll
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master ๎‚ฐ ll -alr
total 0
drwxr-xr-x 10 jake.ko staff 320B 12 2 20:21 .git
drwxr-xr-x 22 jake.ko staff 704B 12 2 20:16 ..
drwxr-xr-x 3 jake.ko staff 96B 12 2 20:17 .
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master ๎‚ฐ echo first > first.txt
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master ๎‚ฐ git add .
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master โœš ๎‚ฐ git commit -m "A"
[master (root-commit) 20611a0] A
1 file changed, 1 insertion(+)
create mode 100644 first.txt
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master ๎‚ฐ echo second > second.txt
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master ๎‚ฐ git add .
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master โœš ๎‚ฐ git commit -m "B"
[master 381d030] B
1 file changed, 1 insertion(+)
create mode 100644 second.txt
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master ๎‚ฐ echo third > third.txt
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master ๎‚ฐ git add .
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master โœš ๎‚ฐ git commit -m "C"
[master 52bfd68] C
1 file changed, 1 insertion(+)
create mode 100644 third.txt
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master ๎‚ฐ

git log

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
commit 52bfd68372367dcbb2b4c1c5bb1ddb1086f02119 (HEAD -> master)
Author: jake.ko <jake.ko@kakaocorp.com>
Date: Sun Dec 2 20:23:30 2018 +0900

C

commit 381d030dafd61153bb3754c260b7216a9b5c47e9
Author: jake.ko <jake.ko@kakaocorp.com>
Date: Sun Dec 2 20:22:52 2018 +0900

B

commit 20611a043cea164d8d3e5f5d73b3949974a5fe50
Author: jake.ko <jake.ko@kakaocorp.com>
Date: Sun Dec 2 20:22:19 2018 +0900

A

git rebase -i HEAD~2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
pick 381d030 B
pick 52bfd68 C

# Rebase 20611a0..52bfd68 onto 20611a0 (2 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

๋ฐ”๊พธ๊ณ  ์ €์žฅ

1
2
3

pick 381d030 B
squash 52bfd68 C

์•„๋ž˜์™€ ๊ฐ™์€ ์ˆ˜์ •์ด ๊ฐ€๋Šฅ , ๋””ํดํŠธ ๊ทธ๋Œ€๋กœ ์ €์žฅ (.git/COMMIT_EDITMSG)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# This is a combination of 2 commits.
# This is the 1st commit message:

B

# This is the commit message #2:

C

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Sun Dec 2 20:22:52 2018 +0900
#
# interactive rebase in progress; onto 20611a0
# Last commands done (2 commands done):
# pick 381d030 B
# squash 52bfd68 C
# No commands remaining.
# You are currently rebasing branch 'master' on '20611a0'.
#
# Changes to be committed:
# new file: second.txt
# new file: third.txt
#

๊ฒฐ๊ณผ

1
2
3
4
5
6
7
jake.ko ๎‚ฐ ~/Dev/git-study ๎‚ฐ ๎‚  master ๎‚ฐ git rebase -i HEAD~2
[detached HEAD 6899e57] B
Date: Sun Dec 2 20:22:52 2018 +0900
2 files changed, 2 insertions(+)
create mode 100644 second.txt
create mode 100644 third.txt
Successfully rebased and updated refs/heads/master

git log

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'git help -a' and 'git help -g' list available subcommands and some
commit 6899e57839eb085a8f0188572aec93ab1b8db74b (HEAD -> master)
Author: jake.ko <jake.ko@kakaocorp.com>
Date: Sun Dec 2 20:22:52 2018 +0900

B

C

commit 20611a043cea164d8d3e5f5d73b3949974a5fe50
Author: jake.ko <jake.ko@kakaocorp.com>
Date: Sun Dec 2 20:22:19 2018 +0900

A
(END)

tags: [git]

Share