만들면서 배우는 Git Github 입문 책을 보며 작성
Administrator@DESKTOP-I327ER6 MINGW64 ~ (master)
$ mkdir git_tutorial
Administrator@DESKTOP-I327ER6 MINGW64 ~ (master)
$ cd git_tutorial/
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git init
Initialized empty Git repository in C:/Users/Administrator/git_tutorial/.git/
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ vim hello.py
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ cat hello.py
print("Hello World")
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add ..." to include in what will be committed)
hello.py
nothing added to commit but untracked files present (use "git add" to track)
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git add hello.py
warning: LF will be replaced by CRLF in hello.py.
The file will have its original line endings in your working directory
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached ..." to unstage)
new file: hello.py
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git commit
[master (root-commit) 4a277db] create "hello world" program
1 file changed, 2 insertions(+)
create mode 100644 hello.py
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git branch
* master
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git branch hotfix
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git branch
hotfix
* master
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git checkout hotfix
Switched to branch 'hotfix'
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ git branch
* hotfix
master
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ ls
hello.py
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ vim hello.py
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ cat hello.py
Hello World
Tell Your World
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ git status
On branch hotfix
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git restore ..." to discard changes in working directory)
modified: hello.py
no changes added to commit (use "git add" and/or "git commit -a")
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ git commit -a
[hotfix e338ae7] added output "Tell Your World"
1 file changed, 2 insertions(+), 1 deletion(-)
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ git status
On branch hotfix
nothing to commit, working tree clean
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ git checkout master
Switched to branch 'master'
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git status
On branch master
nothing to commit, working tree clean
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ ls
hello.py
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git merge hotfix
Updating 4a277db..e338ae7
Fast-forward
hello.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ cat hello.py
Hello World
Tell Your World
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ vi hello.py
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ cat hello.py
Hello World
Tell Your World
Tell his world
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git commit -a
[master d9cfc7d] dded output "Tell his world"
1 file changed, 1 insertion(+)
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git checkout hotfix
Switched to branch 'hotfix'
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ vim hello.py
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ git commit -a
[hotfix c7b4c97] added output "Tell her world"
1 file changed, 1 insertion(+), 1 deletion(-)
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ cd ..
Administrator@DESKTOP-I327ER6 MINGW64 ~ (master)
$ cd git_tutorial/
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ touch .gitignore
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ ls -al
total 33
drwxr-xr-x 1 Administrator 197121 0 3월 23 11:22 ./
drwxr-xr-x 1 Administrator 197121 0 3월 23 11:17 ../
drwxr-xr-x 1 Administrator 197121 0 3월 23 11:17 .git/
-rw-r--r-- 1 Administrator 197121 0 3월 23 11:22 .gitignore
-rw-r--r-- 1 Administrator 197121 46 3월 23 11:16 hello.py
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ vim .gitignore
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ cat .gitignore
# Created by https://www.gitignore.io/api/windows
# Edit at https://www.gitignore.io/?templates=windows
.....
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ git add .gitignore
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ git commit -m "added '.gitignore' files"
[hotfix 5140a77] added '.gitignore' files
1 file changed, 30 insertions(+)
create mode 100644 .gitignore
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (hotfix)
$ git checkout master
Switched to branch 'master'
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git merge hotfix
Auto-merging hello.py
CONFLICT (content): Merge conflict in hello.py
Automatic merge failed; fix conflicts and then commit the result.
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master|MERGING)
$ cat hello.py
Hello World
Tell Your World
<<<<<<< HEAD
Tell his world
=======
Tell her world
>>>>>>> hotfix
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master|MERGING)
$ vi hello.py
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master|MERGING)
$ cat hello.py
Hello World
Tell Your World
Tell his world
Tell her world
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master|MERGING)
$ git commit -a -m "conflict resolved"
[master 2d989c5] conflict resolved
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git log --graph
......
명령어 | 기능 |
git clone | 원격 저장소의 모든 내용을 로컬 저장소로 복사합니다. |
git remote | 로컬 저장소를 특정 원격 저장소와 연결합니다. |
git push | 로컬 저장소의 내용을 보내거나 로컬 저장소의 변경 사항을 원격 저장소로 보냅니다. |
git fetch | 로컬 저장소와 원격 저장소의 변경 사항이 다를 때 이를 비교 대조하고 git merge명력어와 함께 최신 데이터를 반영하거나 충돌 문제 등을 해결합니다. |
git pull | git remote명력을 통해 서로 연결된 원격 저장소의 최신 내용을 로컬 저장소로 가져오면서 병합합니다. git push와 반대 성격의 명령어입니다. |
Administrator@DESKTOP-I327ER6 MINGW64 ~ (master)
$ mkdir github_tutorial
Administrator@DESKTOP-I327ER6 MINGW64 ~ (master)
$ cd github_tutorial/
Administrator@DESKTOP-I327ER6 MINGW64 ~/github_tutorial (master)
$ git clone https://github.com/YJYeon/study.git
Cloning into 'study'...
remote: Enumerating objects: 32, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (29/29), done.
remote: Total 32 (delta 4), reused 28 (delta 1), pack-reused 0
Unpacking objects: 100% (32/32), done.
Administrator@DESKTOP-I327ER6 MINGW64 ~/github_tutorial (master)
$ ls -al
total 28
drwxr-xr-x 1 Administrator 197121 0 3월 23 12:30 ./
drwxr-xr-x 1 Administrator 197121 0 3월 23 12:30 ../
drwxr-xr-x 1 Administrator 197121 0 3월 23 12:30 study/
Administrator@DESKTOP-I327ER6 MINGW64 ~ (master)
$ cd git_tutorial/
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git remote add origin https://github.com/YJYeon/commend_hello.git
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git remote -v
origin https://github.com/YJYeon/commend_hello.git (push)
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
$ git push origin --all
Administrator@DESKTOP-I327ER6 MINGW64 ~/git_tutorial (master)
'프로그램 > Git GitHub' 카테고리의 다른 글
원격 저장소 관리 (0) | 2020.04.01 |
---|---|
원격 저장소 생성 (0) | 2020.03.31 |
이클립스에서 원격 저장소 로컬 세팅 (0) | 2020.03.25 |
이클립스에서 저장소 생성 및 사용법 (0) | 2020.03.25 |