<Git&Github>#1.GitHub_코드저장/버전관리/공유

박서연·2023년 2월 23일

Git&Github

목록 보기
1/2

📌 유용 사이트

🔗 아이콘
https://simpleicons.org/

🔗 배지 활용
https://shields.io/

🔗 markdown 미리보기
https://dillinger.io/

0. 전체적인 흐름

🔅 처음 수정

git과 github 연동 config (Git Bash 이용)

-> history 생성 add - commit

-> history 보낼 github repository 설정 remote

-> 전송 push

🔅 이후 수정

add -> commit -> push

1. git 최초 설정 -Git Bash

  1. github 회원가입

  2. Git Bash 다운로드

  3. git config

git config --global user.name "name"	#주로 github name
git config --global user.email "email"	#github 등록 이메일
  1. git config 확인
git config --list

🔅 git config --list 종료는 Q

2. git 터미널 설정 -VSCode

  1. github에서 새로운 repository 생성

  2. VSCode에서 예시 코드 작성 후 terminal-> New terminal

  3. terminal에서 git 명령어 작성

3. git 명령어

  1. git init
    💡 맨 처음에만 작성하는 명령어
    프로젝트 올릴 때 git init으로 git을 쓸 준비, 즉 초기화한다.

  2. git add
    📌 git add(space). 또는 git add (파일명)
    .은 프로젝트 내에 존재하는 파일 전체를 의미. git add는 어떤 파일을 git에 올릴지 찾아본다. 전자를 이용해 프로젝트 내의 모든 파일을 올릴 수 있고, 후자를 이용해 파일 하나만 올릴 수도 있다.

  3. git status
    상태를 알려주는 명령어로 필수 아님
    add되었을 경우 녹색으로 나타남

  4. git commit
    📌 git commit -m "first commit"
    git commit은 history 만드는 것을 의미하며 -m 뒤에 history명 작성
    first commit은 최종이라는 의미로, 최종, 최종_수정, 진짜 최종 등 history를 보여주는 역할

  5. git remote
    📌 git remote add origin (HTTPS 또는 SSH 주소 복붙)
    🔅 추가: git remote add origin (HTTPS 또는 SSH 주소 복붙)
    🔅 수정: git remote set-url origin (HTTPS 또는 SSH주소 복붙)
    🔅 삭제: git remote remove origin

💡 add는 처음 로컬 프로젝트와 깃허브 사이 연결할 때에만 사용

❓ 전자와 같이 작성하였을 때 오류 발생
ssh: connect to host gmail.com port 22: Network is unreachable
fatal: Could not read from remote repository.

🔅 SSH key를 생성하지 않았는데 SSH 주소를 넣었음
두번째 코드 작성해 저장소 주소 수정

  1. git remote -v
    로컬 프로젝트와 깃허브 사이의 연결을 확인하는 명령어로 필수 아님

  2. git push
    📌 git push origin master
    master branch로 파일 전송

reference https://www.youtube.com/watch?v=lelVripbt2M

0개의 댓글