사내 스터디로 팀원 4명이서 약 6개월동안 이 책을 기반으로 깃허브 스터디를 진행했다.
이는 그에 대한 기록이다.
아는 부분도 많았지만 생각보다 몰랐던 부분도 많아 스터디하는 동안 git에 대한 생각 정립이 되었다.
https://www.aladin.co.kr/shop/wproduct.aspx?ItemId=316493887
팀 개발을 위한 Git, GitHub 시작하기
<팀 개발을 위한 Git, GitHub 시작하기>가 실무에 적절한 명령어와 용어, 협업에 100% 활용할 수 있는 내용이 추가된 개정판으로 돌아왔다. 이 책은 시나리오를 곁들인 실습으로 구성되어 깃&깃허브
www.aladin.co.kr
스터디에는 이 책을 사용하였고, 시간 관계상 + 회사에서 실제로 소스트리를 쓰고 있기 때문에 소스트리 파트까지만 진행했다.
책 내용이 전반적으로 쉽게 써있고, 난이도도 낮다.
딱 깃허브 실습만을 위해서 txt 파일만을 이용하고 있다 보니 개발과 git 사용을 병행하긴 어렵다는 점 참고! 대신 그만큼 빠르게 진행할 수 있다는 장점이 있다.
로컬 저장소에서 git 관리
$ cd ~/Desktop/Programming/iTshirt-cat
$ git init
Initialized empty Git repository in C:/Users/user/Desktop/Programming/iTshirt-cat/.git/
디렉터리에 .git 디렉터리가 생긴다. 이는 로컬 저장소이다.
이 폴더에서 버전 관리를 할 수 있다.
$ git config --global user.email "4shchoi4@gmail.com"
$ git config --global user.name "4SohyunChoi4"
$ git add README.txt
$ git commit -m "사이트 설명 추가"
[master (root-commit) 83ed1d4] 사이트 설명 추가
1 file changed, 1 insertion(+)
create mode 100644 README.txt
$ cat README.txt
개발자 티셔츠 쇼핑몰 오픈소스
$ vi README.txt
개발자 티셔츠 쇼핑몰 오픈소스
2번째
$ git add README.txt
warning: in the working copy of 'README.txt', LF will be replaced by CRLF the next time Git touches it
$ git commit -m "설명 업데이트"
[master fd8b96f] 설명 업데이트
1 file changed, 2 insertions(+), 1 deletion(-)
두 번째 커밋 생성이 완료되었다.
$ git log
commit fd8b96f9898b1a5c9b58cf705ed13ec17f952d3c (HEAD -> master)
Author: 4SohyunChoi4 <4shchoi4@gmail.com>
Date: Tue Jul 30 10:21:55 2024 +0900
설명 업데이트
commit 83ed1d4701d6ae9b0b0a1c6b1669c886dc57b7d0
Author: 4SohyunChoi4 <4shchoi4@gmail.com>
Date: Tue Jul 30 10:14:53 2024 +0900
사이트 설명 추가
git checkout : 해당 커밋으로 되돌아갈 수 있다.
$ git checkout 83ed1d4701d6ae9b0b0a1c6b1669c886dc57b7d0
Note: switching to '83ed1d4701d6ae9b0b0a1c6b1669c886dc57b7d0'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 83ed1d4 사이트 설명 추가
$ cat README.txt
개발자 티셔츠 쇼핑몰 오픈소스
첫 커밋으로 돌아갔다.
$ git checkout -
Previous HEAD position was 83ed1d4 사이트 설명 추가
Switched to branch 'master'
$ cat README.txt
개발자 티셔츠 쇼핑몰 오픈소스
2번째
최신 커밋으로 돌아갔다.
Github 원격저장소 사용하기
Repository를 생성한다.
링크를 통해 원격 저장소에 접속할 수 있다.
원격 저장소에 커밋 올리기
$ git remote add origin <https://github.com/4SohyunChoi4/iTshirt.git>
로컬 저장소에 연결할 원격 저장소 주소를 알려준다.
$ git branch -M main
main이라는 branch를 생성한다.
origin(원격 저장소)의 main branch에 내 커밋을 push한다.
$ git push origin main
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 578 bytes | 144.00 KiB/s, done.
Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
To <https://github.com/4SohyunChoi4/iTshirt.git>
* [new branch] main -> main
원격 저장소에 올라와 있는 모습을 확인할 수 있다.
Github 원격 저장소의 커밋을 로컬 저장소에 내려받기
- 클론 : 원격 저장소의 코드와 버전 전체를 내 컴퓨터로 내려받는 것
즉, 원격 저장소를 복제하는 것이다.
$ ls
iTshirt-cat/
$ mkdir iTshirt-oct
$ ls
iTshirt-cat/ iTshirt-oct/
oct 저장소에서 cat의 커밋을 내려받기 위해 폴더를 생성한다.
download ZIp으로 하게 되면 원격 저장소와 버전 정보가 제외되므로 클론을 하는 것이 권장된다.
$ git clone <https://github.com/4SohyunChoi4/iTshirt.git> .
Cloning into 'iTshirt'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 6 (delta 0), pack-reused 0
Receiving objects: 100% (6/6), done.
현재 디렉토리에 클론한다.
발생한 오류
$ git clone https://github.com/4SohyunChoi4/iTshirt.git .
Cloning into '.'...
fatal: unable to access 'https://github.com/4SohyunChoi4/iTshirt.git/': Could not resolve host: github.com
인터넷에 연결되지 않아서 생긴 문제
개발자 티셔츠 쇼핑몰 오픈소스
2번째
개발자 목록
1. 고양이
2. 문어
$ vi README.txt
$ git add README.txt
$ git commit -m "개발자 목록 추가"
[main 89aad23] 개발자 목록 추가
1 file changed, 4 insertions(+)
$ git push origin main
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 366 bytes | 183.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To <https://github.com/4SohyunChoi4/iTshirt.git>
fd8b96f..89aad23 main -> main
방금 푸시한 ‘개발자 목록 추가’ 커밋이 올라와 있다.
변경된 README.txt 도 확인할 수 있다.
로컬 저장소의 새로운 커밋을 로컬 저장소에 갱신하기
$ cd iTshirt-cat/
$ git pull origin main
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 346 bytes | 16.00 KiB/s, done.
From <https://github.com/4SohyunChoi4/iTshirt>
* branch main -> FETCH_HEAD
fd8b96f..89aad23 main -> origin/main
Updating fd8b96f..89aad23
Fast-forward
README.txt | 4 ++++
1 file changed, 4 insertions(+)
$ cat README.txt
개발자 티셔츠 쇼핑몰 오픈소스
2번째
개발자 목록
1. 고양이
2. 문어
최신 커밋으로 경신되었다.
'Coding > git' 카테고리의 다른 글
[팀 개발을 위한 Git, GitHub 시작하기] - Ch 4. 둘 이상의 원격 저장소로 협업하기 (0) | 2023.09.10 |
---|---|
[팀 개발을 위한 Git, GitHub 시작하기] - Ch 3. 여러 명이 함께 Git으로 협업하기 (0) | 2023.09.05 |
작년과 올해, 깃 변화 (0) | 2021.12.31 |
방학동안 1일 1커밋 해봤다 (0) | 2021.09.11 |
git pull 할 때 Your local changes to the following files would be overwritten by merge 오류 (0) | 2021.05.03 |