잡동사니에도 사랑을

[Git] git 명령어 사용 예제(2) 본문

정리/Git정리

[Git] git 명령어 사용 예제(2)

luvforjunk 2021. 11. 10. 16:09
728x90
반응형

[21.11.10] git(2)

 

원격에서 로컬로

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d
$ cd d:

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d
$ cd D:\git_home

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home
$ ll
total 0

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home
$ ls -la
total 8
drwxr-xr-x 1 bitcamp 197121 0 Nov 10 15:50 ./
drwxr-xr-x 1 bitcamp 197121 0 Nov  9 18:00 ../

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home
$ git clone https://github.com/luvforjunk/git_exam.git -- 만들어 둔 레퍼지토리를 클론시킴
Cloning into 'git_exam'...
warning: You appear to have cloned an empty repository.

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home
$ ll
total 0
drwxr-xr-x 1 bitcamp 197121 0 Nov 10 15:58 git_exam/

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home
$ cd git_exam

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_exam (main)
$ ls -la
total 4
drwxr-xr-x 1 bitcamp 197121 0 Nov 10 15:58 ./
drwxr-xr-x 1 bitcamp 197121 0 Nov 10 15:58 ../
drwxr-xr-x 1 bitcamp 197121 0 Nov 10 15:58 .git/ -- git저장소

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_exam (main)
$ vi aa.txt -- i를 누른 뒤 내용을 입력하고, 저장하고 나가고 싶으면, ESC+:wq / 아니면 ESC+:q!

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_exam (main)
$ ll
total 1
-rw-r--r-- 1 bitcamp 197121 12 Nov 10 16:01 aa.txt

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_exam (main)
$ git status
On branch main

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        aa.txt

nothing added to commit but untracked files present (use "git add" to track)

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_exam (main)
$ git add aa.txt -- git 공간으로 aa.txt를 관리대상자로 올림
warning: LF will be replaced by CRLF in aa.txt.
The file will have its original line endings in your working directory

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_exam (main)
$ ll
total 1
-rw-r--r-- 1 bitcamp 197121 12 Nov 10 16:01 aa.txt

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_exam (main)
$ git status
On branch main

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   aa.txt

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_exam (main)
$ git commit -m "aa.txt 생성" -- 메시지와 함께 커밋시킨다. 원격은 커밋 상태를 알지 못함.
[main (root-commit) b633728] aa.txt 생성
 1 file changed, 1 insertion(+)
 create mode 100644 aa.txt
 
 bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_exam (main)
$ git push -u origin main -- GitHub에 origin으로 푸쉬시키기
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 229 bytes | 229.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/luvforjunk/git_exam.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

 

 

로컬에서 원격으로 올리는 방법

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_tutorial (main)
$ git remote add origin https://github.com/luvforjunk/git_tutorial.git

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_tutorial (main)
$ echo "만다린은귤" >> README.md

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_tutorial (main)
$ ll
total 1
-rw-r--r-- 1 bitcamp 197121 16 Nov 10 16:31 README.md

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_tutorial (main)
$ cat README.md
만다린은귤

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_tutorial (main)
$ git add README.md
warning: LF will be replaced by CRLF in README.md.
The file will have its original line endings in your working directory

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_tutorial (main)
$ git commit -m "first commit"
[main (root-commit) 53b3577] first commit
 1 file changed, 1 insertion(+)
 create mode 100644 README.md

bitcamp@DESKTOP-6C6JPQJ MINGW64 /d/git_home/git_tutorial (main)
$ git push -u origin main -- main안에 있는 것을 깃허브에 올리기
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 228 bytes | 228.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/luvforjunk/git_tutorial.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

 

728x90
반응형

'정리 > Git정리' 카테고리의 다른 글

[Git] git 명령어 사용 예제(1)  (0) 2021.11.09