GitBash Download Link
Git for Windows
Git for Windows focuses on offering a lightweight, native set of tools that bring the full feature set of the Git SCM to Windows while providing appropriate user interfaces for experienced Git users and novices alike. Git BASH Git for Windows provides a BA
gitforwindows.org
위 링크에서 gitbash를 다운받아 줍니다!
필요한 것은 총 3가지에요
- github 계정
- gitbash
- github에 올릴 폴더
Github에서 Repository 만들기
Repository 이름을 적은 다음, 사용 목적에 맞게 공개, 비공개 선택을 해줍니다. 선택 후 Create!
그럼 이렇게 저장소가 생성됩니다!
원하는 폴더 Github에 올리기
Git config (최초 1회만 실행)
// git user name 설정
git config --global user.name "git_user_name"
// git email 설정
git config --global user.email "user_email@gmail.com"
Git init
현재 디렉토리를 로컬 저장소로 설정한다. 이미 디렉토리로 이동해있으므로 따로 경로를 지정해줄 필요는 없다.
//로컬 저장소로 설정
git init
repository 접근
저장소의 clone url을 이용해서 저장소에 접근할 것이다.
git clone {repository address}
끝에 (branch name)이 뜬다면 연결 완료!
Git add
파일을 Staging Area로 옮기는 것이다. (Staging Area - 커밋 예정인 내용들을 기억하는 공간)
이 작업은 변경사항이 저장소에 커밋되기 전에 반드시 거쳐야만 하는 중간단계에 속한다.
// test.html 파일만 추가
git add test.html
// 워킹 디렉터리 내 모든 파일을 추가
git add .
Git Commit
Staging Area의 파일을 로컬 저장소에 저장하는 것이다.
// 커밋 메시지를 입력후 커밋
git commit -m "입력하고자 하는 커밋 메시지"
Git push
원격 저장소에 저장하는 것이다.
// 원격저장소에 저장
git push origin master
여기서 master는 branch name으로 repository마다 다를수도 있다! 현재 접속해있는 branch name으로 해주면 된다.
Git branch
브랜치 관리를 담당하는 명령어들
// 브랜치 목록 보기
git branch
// 브랜치 생성
git branch {브랜치명}
// 브랜치 수정
git branch -m {브랜치명} {바꿀 브랜치명}
//브랜치 삭제
git branch -d {브랜치명}
Git checkout
워킹 디렉토리의 소스를 특정 커밋, 브랜치로 변경 시 사용할 수 있는 명령어
// 특정 브랜치로 워킹 디렉토리 변경
git checkout {브랜치명}
// 특정 커밋으로 워킹 디렉토리 변경
git checkout {commit ID}
Git merge
브랜치 병합 시 사용하는 명령어
// master branch에 develop branch를 병합!
git checkout master
git merge develop
참고 자료
- https://gbsb.tistory.com/10
- https://cau-meng2.tistory.com/7
'기타 공부들' 카테고리의 다른 글
[Git] Pycharm과 Git 연동하기 (0) | 2021.11.03 |
---|---|
[Javascript / CSS / HTML ] 내 컴퓨터에 저장된 이미지 업로드 하기(화면에 업로드된 이미지 보여주기) (0) | 2021.11.02 |
[Python] BeautifulSoup으로 크롤링하기 (네이버 영화순위) (0) | 2021.10.11 |
[Javascript] AJAX 사용하기 (0) | 2021.10.08 |
[Javascript] JQuery 사용법 (0) | 2021.10.07 |