본문 바로가기
컴퓨터/TIL

[Git]git 기초

by stubborngastropod 2023. 1. 12.
728x90

git bash 설치

https://git-scm.com/download/win

 

Git - Downloading Package

Download for Windows Click here to download the latest (2.39.0) 32-bit version of Git for Windows. This is the most recent maintained build. It was released 22 days ago, on 2022-12-21. Other Git for Windows downloads Standalone Installer 32-bit Git for Win

git-scm.com

 

git은 분산 버전 관리 프로그램이다.

CLI 상에서 add, commit, push 과정을 거쳐 코드를 업데이트하고 리뷰할 수 있다.

 

코드는 작업이 이루어지는 working directory에서 add를 통해 특정 버전으로 관리하고 싶은 파일이 있는 곳인 staging area로 이동되며 commit을 통해 repository에 저장된다. 이후 push 과정을 거쳐 github에 publish된다.

 

기본 명령어

cd / #change directory
ls #list
mkdir #make directory
touch #make file
git status #status
git log #log
git clone #clone, download
git pull #update

add/commit/push

git init #initailize
git add . #working directory -> staging area
git commit #staging area -> repository
git commit -m "commit_message"
git remote add name url
git push #publish

branch

git branch #current branch
git checkout #move out/in to branch
git checkout -b "branch" #make and move to branch
git branch -d "branch" #delete
git branch push origin "branch" #push to branch

 

협업시, 상대방의 repository를 fork 하여 수정 후 pull request(pr)할 수 있다.

pr이 merge되면 해당 내용대로 코드가 업데이트된다.

728x90

'컴퓨터 > TIL' 카테고리의 다른 글

[Java]변수와 자료형  (0) 2023.01.07

댓글