728x90
1. 브랜치(branch) 생성 : branch
$ git branch 브랜치명
예시
$ git branch test1
2.브랜치(branch) 변경 : checkout
$ git checkout 브랜치명
※ 브랜치(branch) 생성 및 변경 한번에
-b 추가
$ git checkout **-b** 브랜치명
3.Merge
$ git **merge** <commit>
4. 브랜치(branch) 삭제 : branch -d
$ git **branch -d** 브랜치명
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository
$ git init
Initialized empty Git repository in D:/Git_Repository/.git/
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch -b test1
error: unknown switch `b'
usage: git branch [<options>] [-r | -a] [--merged] [--no-merged]
or: git branch [<options>] [-f] [--recurse-submodules] <branch-name> [<start-point>]
or: git branch [<options>] [-l] [<pattern>...]
or: git branch [<options>] [-r] (-d | -D) <branch-name>...
or: git branch [<options>] (-m | -M) [<old-branch>] <new-branch>
or: git branch [<options>] (-c | -C) [<old-branch>] <new-branch>
or: git branch [<options>] [-r | -a] [--points-at]
or: git branch [<options>] [-r | -a] [--format]
Generic options
-v, --verbose show hash and subject, give twice for upstream branch
-q, --quiet suppress informational messages
-t, --track[=(direct|inherit)]
set branch tracking configuration
-u, --set-upstream-to <upstream>
change the upstream info
--unset-upstream unset the upstream info
--color[=<when>] use colored output
-r, --remotes act on remote-tracking branches
--contains <commit> print only branches that contain the commit
--no-contains <commit>
print only branches that don't contain the commit
--abbrev[=<n>] use <n> digits to display object names
Specific git-branch actions:
-a, --all list both remote-tracking and local branches
-d, --delete delete fully merged branch
-D delete branch (even if not merged)
-m, --move move/rename a branch and its reflog
-M move/rename a branch, even if target exists
-c, --copy copy a branch and its reflog
-C copy a branch, even if target exists
-l, --list list branch names
--show-current show current branch name
--create-reflog create the branch's reflog
--edit-description edit the description for the branch
-f, --force force creation, move/rename, deletion
--merged <commit> print only branches that are merged
--no-merged <commit> print only branches that are not merged
--column[=<style>] list branches in columns
--sort <key> field name to sort on
--points-at <object> print only branches of the object
-i, --ignore-case sorting and filtering are case insensitive
--recurse-submodules recurse through submodules
--format <format> format to use for the output
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test1
fatal: not a valid object name: 'master'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git help
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
[--super-prefix=<path>] [--config-env=<name>=<envvar>]
<command> [<args>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an existing one
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
restore Restore working tree files
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
bisect Use binary search to find the commit that introduced a bug
diff Show changes between commits, commit and working tree, etc
grep Print lines matching a pattern
log Show commit logs
show Show various types of objects
status Show the working tree status
grow, mark and tweak your common history
branch List, create, or delete branches
commit Record changes to the repository
merge Join two or more development histories together
rebase Reapply commits on top of another base tip
reset Reset current HEAD to the specified state
switch Switch branches
tag Create, list, delete or verify a tag object signed with GPG
collaborate (see also: git help workflows)
fetch Download objects and refs from another repository
pull Fetch from and integrate with another repository or a local branch
push Update remote refs along with associated objects
'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test
fatal: not a valid object name: 'master'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test1
fatal: not a valid object name: 'master'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch master
fatal: not a valid object name: 'master'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git checkout test1
error: pathspec 'test1' did not match any file(s) known to git
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git checkout test
error: pathspec 'test' did not match any file(s) known to git
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch a
fatal: not a valid object name: 'master'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ ls -al
total 20
drwxr-xr-x 1 csy62 197609 0 Jul 31 03:18 ./
drwxr-xr-x 1 csy62 197609 0 Jul 14 08:20 ../
drwxr-xr-x 1 csy62 197609 0 Jul 31 03:17 .git/
-rw-r--r-- 1 csy62 197609 0 Jul 31 03:18 a.txt
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test
fatal: not a valid object name: 'master'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch 'test'
fatal: not a valid object name: 'master'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git commit -m 1
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
a.txt
nothing added to commit but untracked files present (use "git add" to track)
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git add a.txt
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git commit -m 1
[master (root-commit) 0505a6a] 1
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a.txt
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch -m test1
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
test
* test1
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test
Switched to branch 'test'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test)
$ git checkout -b test2
Switched to a new branch 'test2'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch
test
test1
* test2
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test
Switched to branch 'test'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test)
$ git branch -m test0
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test0)
$ git branch
* test0
test1
test2
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test0)
$ git branch -d test2
Deleted branch test2 (was 0505a6a).
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test0)
$ git checkout -b test2
Switched to a new branch 'test2'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Already up to date.
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 1
On branch test2
nothing to commit, working tree clean
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch
test0
test1
* test2
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch -d test2
error: Cannot delete branch 'test2' checked out at 'D:/Git_Repository'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout -b test3
Switched to a new branch 'test3'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test3)
$ git checkout test2
Switched to branch 'test2'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch -d test3
Deleted branch test3 (was 0505a6a).
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test2
Already on 'test2'
A "a - \353\263\265\354\202\254\353\263\270.txt"
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'
A "a - \353\263\265\354\202\254\353\263\270.txt"
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Already up to date.
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'
A "a - \353\263\265\354\202\254\353\263\270.txt"
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 1
[test2 76d033f] 1
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 "a - \353\263\265\354\202\254\353\263\270.txt"
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test1
Already up to date.
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge test3
merge: test3 - not something we can merge
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge test1
Already up to date.
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch
test0
test1
* test2
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge master
merge: master - not something we can merge
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git show
commit 76d033f78943e8d9856b60b2c323dd80098a23fe (HEAD -> test2)
Author: neverGiveUpppppp <csy6219@naver.com>
Date: Sun Jul 31 03:30:07 2022 +0900
1
diff --git "a/a - \353\263\265\354\202\254\353\263\270.txt" "b/a - \353\263\265\354\202\254\353\263\270.txt"
new file mode 100644
index 0000000..e69de29
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git status
On branch test2
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 1
[test2 c0f83ba] 1
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge
fatal: No remote for the current branch.
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git test1
git: 'test1' is not a git command. See 'git --help'.
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Updating 0505a6a..c0f83ba
Fast-forward
...65\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt" | 0
"a - \353\263\265\354\202\254\353\263\270.txt" | 0
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"
create mode 100644 "a - \353\263\265\354\202\254\353\263\270.txt"
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git status
On branch test1
nothing to commit, working tree clean
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git show
commit c0f83baab10cff7a90120db6ba4f3975c3e743f7 (HEAD -> test1, test2)
Author: neverGiveUpppppp <csy6219@naver.com>
Date: Sun Jul 31 03:32:43 2022 +0900
1
diff --git "a/a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt" "b/a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"
new file mode 100644
index 0000000..e69de29
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
test0
* test1
test2
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 2
[test2 d4529f8] 2
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git add .
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git commit -m 3
On branch test1
nothing to commit, working tree clean
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
test0
* test1
test2
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test3
error: pathspec 'test3' did not match any file(s) known to git
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch -d test2
error: The branch 'test2' is not fully merged.
If you are sure you want to delete it, run 'git branch -D test2'.
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Updating c0f83ba..d4529f8
Fast-forward
...65\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt" | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch -d test2
Deleted branch test2 (was d4529f8).
csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
test0
* test1
728x90
반응형
'small steps > 1일 1코딩 - 코딩을 내 몸처럼' 카테고리의 다른 글
[1일1코딩][Web] 보드디테일뷰 3rd (0) | 2022.08.06 |
---|---|
[1일1코딩][Web] boardDetailView.jsp 2nd (0) | 2022.08.05 |
[1일1코딩][JS] addEventListener & removeEventListener (0) | 2022.08.03 |
[1일1코딩][Java] 간단 입출금,잔액조회 (0) | 2022.08.02 |
[1일1코딩][Java] 얕은 복사(shallow copy) (0) | 2022.08.01 |