Git 및 Github 사용하기
Source: Dev.to

Git이란?
Git은 무료이자 오픈‑소스인 분산 버전‑컨트롤 시스템입니다. 파일 집합의 변경 사항을 추적하며, 주로 소스‑코드 프로젝트에서 협업하는 프로그래머들 사이에 작업을 조정하는 데 가장 많이 사용됩니다.
필수 Git 명령
| Command | Description |
|---|---|
git push | 로컬 저장소 내용을 원격 저장소에 업로드합니다. |
git commit -m "" | 설명 메시지를 포함하여 저장소의 스냅샷을 기록합니다. |
git add <file> | 작업 디렉터리의 변경 사항을 다음 커밋을 위해 스테이징합니다. |
git remote add origin <url> | 새 원격 저장소(보통 GitHub)를 등록합니다. |
git remote -v | 현재 원격 URL 목록을 표시합니다. |
git config --list | 현재 Git 설정을 보여줍니다. |
Note: 저장소의 원격 URL이 필요하며, 필요할 경우 인증 자격 증명이 필요합니다.
로컬 환경에서 GitHub로 푸시하는 방법
- Git Bash 다운로드 – OS와 호환되는 버전을 선택하세요.
- Git Bash 설정 – Git에 본인의 신원을 알려줍니다.
- 설정된 환경에서 작업하기 – 프로젝트 폴더를 만들고, 저장소를 초기화하는 등.
- GitHub 저장소 클론 – 기존 원격 저장소를 로컬로 가져옵니다.
- GitHub에 푸시 – 로컬 커밋을 원격에 전송합니다.
- 내용 확인 – 모든 것이 정상인지 확인합니다.
1️⃣ Git Bash 다운로드
공식 사이트에서 최신 Git for Windows를 설치하세요:
2️⃣ Git Bash 설정 (신원 지정)
# Set your name (replace <name> with your actual name)
git config --global user.name ""
# Set your email (replace <email> with your actual email)
git config --global user.email ""

# Verify the configuration
git config --list
3️⃣ 설정된 환경에서 작업하기
# Create a directory for your project
mkdir website
# Enter the directory
cd website
# Initialise a new Git repository
git init
# Check the repository status
git status

# Create an index.html file
touch index.html
# Open it with vim (or any editor you prefer)
vim index.html
vim에서는
i를 눌러 Insert 모드로 들어가 파일을 편집한 뒤,Esc를 누르고:wq를 입력해 저장하고 종료합니다.
4️⃣ 추가, 커밋 및 푸시
# Stage the new file
git add index.html
# Commit with a message
git commit -m "Add initial index.html"
# Add the remote repository (replace <url> with your GitHub repo URL)
git remote add origin
# Push the commit to the remote master/main branch
git push -u origin master # or `main` if your default branch is named main5️⃣ GitHub에서 확인
GitHub에서 저장소 페이지를 열어 index.html이 파일 목록에 나타나는지 확인하세요.
코딩 즐겁게! 🎉
문제가 발생하면 원격 URL을 다시 확인하고, 자격 증명(SSH 키 또는 개인 액세스 토큰)이 올바르게 설정되어 있는지 확인하세요.
Source: …
GitHub 저장소 복제하기
Go to your GitHub page – click the + button and select New repository.

Initialize the repository (add a README, .gitignore, license, etc.) and click Create repository.

Copy the HTTPS URL
On the next page click Code → HTTPS and copy the URL that appears.

Clone the repository locally
Open Git Bash (or your preferred terminal) and run:
git remote add origin
GitHub에 푸시하기
우리는 스테이징 영역에 추가한 index.html 파일을 이동시키고, 커밋한 뒤, 원격 저장소에 푸시해야 합니다.
상태 확인
git status
파일 스테이징
git add index.html
스테이징 확인
git status파일 이름이 녹색으로 표시되어 스테이징 되었음을 나타냅니다.

변경 커밋
git commit -m "Add index.html"
GitHub에 푸시
git push origin master
내용 보기
GitHub Pages URL(또는 저장소의 원시 파일 보기)을 열어 index.html이 이제 라이브 상태인지 확인하세요.

모든 이미지는 원본 출처를 유지합니다; 가독성을 위해 마크다운 구조만 정리되었습니다.
시간을 내어 주셔서 감사합니다. 다음 포스트에서 뵙겠습니다.

