AIFFEL_LMS

[F02-6~02-12] Github / add, staging, commit

HyunJung_Jo 2021. 1. 6. 23:43

Local (git) --add--> Staging --commit--> Remote (github)

지옥에서 온 Git

1. GitHub setting

- git --version

- sudo apt-get install git

- github 회원 가입

 

2. Local

- 계정 등록

    - $ git config --global user.email "my-email@gmail.com"

      $ git config --global user.name "my-username"

- git config -l 으로 확인

 

-local 저장소 만들기

    $ cd ~

    $ mkdir workplace

-Git 으로 버전 관리 시작

    $ cd workplace

    $ git init

    

    $ ls -a

    . .. .git

    $ cd .git

    $ ls

    HEAD branches config description hooks info objects refs

 

3.Staging ; 변화추적하기

-README.md 생성 (.git이 아닌 해당 로컬 디렉토리에서 생성한다)

    레퍼지토리 대문 역할

 

    $ echo "# first-repository" >> README.md

    $ ls

    README.md

    $ cat README.md

    # first-repository

 

- Git이 추적하는 변화 확인하기

$ git status

On branch master

No commits yet

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

README.md

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

 

-git에 변경사항 저장하기 by add, commit

$ git add README.md

$ git commit -m “new readme file”  ( -m은 메시지 옵션)

[master (root-commit) 438a37c] new readme file

1 file changed, 1 insertion(+) create mode 100644 README.md

 

4. Remote / Repository

-Github에 repository 생성

 

5. local & remote 연결

-remote 주소를 git에게 알려줘서 연결 / 주소는 복붙해서 붙이기

- $ cd ~/workplace

  $ git remote add origin https://github.com/username/first-repository.git

 

6.Push :  Local -> Remote // send record from local to remote repository

$ git push origin master

= master branch로 모든 기록을 push하겠다.

 

7. Remote -> Local

- 너와!나의!연결!고리! Repository 주소를 복사

- $ cd ~ $ mkdir project $ cd project

- $ git clone https://github.com/xxx/first-repository.git

 

-확인하기

$ ls

aiffel

$ cd aiffel

$ ls

README.md

$ cat README.md

 

8. remote -> local -> remote

 

# 내용 추가

$ echo "add new contents" >> README.md

 

# 확인

$ cat README.md

# first-repository

add new contents

 

$ git status

On branch master

Changes not staged for commit:

(use "git add <file>..." to update what will be committed)

(use "git restore <file>..." to discard changes in working directory)

    modified: README.md

no changes added to commit (use "git add" and/or "git commit -a")

 

# add, commit => 새로운 스냅샷 저장

$ git add README.md

$ git commit -m “new contents”

[master c82640d] new contents 1 file changed, 1 insertion(+)

 

# 원격 저장소로 전송

$ git push origin master

 

9. Pull - Remote -> Local : 로칼을 원격과 같게 업뎃하기

$ cd ~/workplace

$ git pull origin master

 

##정리##

 

협업 시 파일을 전송할 필요 없이 깃헙에서만 푸쉬, 풀만으로 협업 가능

동시 개발/ 여러 개의 파일 작업 / 버전의 다양성이 있을 경우

파일 관리를 간소화 시키기 위한 작업임

 


생각보다 좀 어려운데, 평소에 그냥 vscode에서 깃헙에 푸쉬 하거나 그냥 파일 업로딩으로 끝내버려서 명령어로 푸쉬 풀하는 것에 익숙해지려면 시간이 걸릴 듯하다.

'AIFFEL_LMS' 카테고리의 다른 글

[F 3-5] 변수의 유효범위 : scope  (0) 2021.01.08
[F 02-13~] Jupyter notebook - 데이터 분석계의 워드  (0) 2021.01.07
Terminal로 패키지 관리하기 - apt-get  (0) 2021.01.04
CLI vs IDE  (0) 2021.01.04
Anaconda Cheatsheat  (0) 2021.01.04