Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

개발공부일지

Github - Repositories, token, 본문

ETC

Github - Repositories, token,

보람- 2023. 8. 22. 15:00

목차

1. 원격저장소란?

2. Repositories 만들기

3. 실습


 

 

 

1. 원격저장소란?

- 작업하던 로컬 컴퓨터가 고장나거나 복구할수없을때 커밋들을 되찾을수없는데 usb에 저장해놓은게 아니라면, 원격저장소에 저장해두어 사용한다.
- 원격 저장소는 내가 작업한 커밋을 올려두는곳

- 나의 모든 커밋을 보내는 행위

 

- main 브랜치에 바로 커밋하지않고, 브랜치를 따로 만들어서 거기에서 작업한다.

- 작업 후에 main에서 작업한 브랜치를 merge해준다.

 

- git을 저장하는 원격저장소로 github를 사용

http://github.com 

 

GitHub: Let’s build from here

GitHub is where over 100 million developers shape the future of software, together. Contribute to the open source community, manage your Git repositories, review code like a pro, track bugs and fea...

github.com

 

 

 

 

2. Repositories 만들기


Repo에 commit 올리기 (WSL2를 사용해서)
   - 내가 만든 저장소는 나만 올려야한다!
       - 내가 나임을 증명하기
           - github ID/PW : 보안적으로 취약함 (github는 통신), 이제 사용하지않아
           - github사이트에서 setting → develop settings → Tokens(classic)

 


② 내가 나임을 증명하는 방법으로 Token을 사용
     - 토큰이란 임의의 키값이다.
         - 사람이 외울수없는 정도의 길이로 이루어져있음
         - 토큰별로 설정을 할수도 있다! (교수님은 컴퓨터 마다 토큰이 있다고하심)

     - 토큰은 만료기간 설정과 권한 설정을 할수있다 → 보안강화

 


토큰 저장
      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

   - 이 토큰을 저장하는 공간이 `OS`마다 존재한다.

       → MAC keychain , WINDOW 자격증명 (window는 까다로워)

    - git 자체에서도 저장하는 공간이 존재한다.

 

 

 

 

 

 

 

**** github 자격증명 추가하기 (window)

 

cd ~
mkdir github
cd github

git config --list

git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager-core.exe"

## github connection

https://github.com/kimboram22/code.git

git init

echo "# code" >> README.md
#파일을 만들면서 내보낸다
echo "# 저장소입니다" >> README.md
cat README.md

git remote add origin https://github.com/kimboram22/code.git
# 오리진은 그냥 주소의 이름을 오리진이라고 하겠다는 것 aa라고 해도 상관없다.
# 내 로컬저장소에서 remote를 추가할건데 이름은 오리진이고 주소를 알려주는것

git remote add aa https://github.com/kimboram22/code.git

git remote
git push aa main

명령어

- git remote : 원격저장소에 연결하는것

- git push : 원격저장소에 올리는것

- git pull : 내 로컬에 .git 디렉토리가 있을 때,  원격저장소에서 가져오는 것

- git clone : 저장소에 있는 전부를 그대로 가져오는 것 (모든 커밋 내용을 받는것)

 

 

3. 실습

1. 내가 작업하는 것 view, delete 
2. feature/board/view와 feature/board/delete 브랜치를 만들고 작업
3. 작업한것을 push하고 main에서 pull 하고 merge한다음 push 
#main에서
git branch feature/board/view 
git branch feature/board/delete
git switch feature/board/delete

#delete애서
vi delete.json 
git add delete.json
git commit -m "feat: delete.json 설정"
git push origin feature/board/delete
git switch main

#main에서
git pull origin main
git merge feature/board/delete
git push origin main
git switch feture/board/view

#view에서
vi view.json
git add view.json
git commit -m "feat: view.json 설정"
vi view.json 
git add view.json
git commit -m "fix: view.json 수정"
git push origin feature/board/view
git switch main

#main에서
git pull origin main
git merge feature/board/view
git push origin main

 

 

 


※ 토큰 처음 만들때 알려주는 번호 복사해두기! (처음 만들었을때만 알려줘서 까먹었다면 그냥 토큰 다시 만들기로!!)

 

※ 원격 브랜치 삭제하기 (강제로 삭제할때는 -D)

git push [원격 저장소 이름] -d [원격 브랜치 이름]

※ git reset --hard [커밋해시값] 

 

※ window 파일경로에서 \ 역슬래시 주의!!!

`C:\Program Files\Git\mingw64\bin\git-credential-manager-core.exe`

리눅스에서 "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager-core.exe"

 

'ETC' 카테고리의 다른 글

Github - Pull requests, forks  (0) 2023.08.23
Git ② - Branch, merge, rebase  (0) 2023.08.21
Git ① - git workflow, git add, git commit  (0) 2023.08.18
Linux ② - User , Shell, Process, Package Manager  (1) 2023.08.17
AWS , PuTTY , FileZilla, apache  (0) 2023.08.16