[VSCODE] Github 에 반영하기 (git commit/push)
git clone 하여 local PC 에 코드를 sync 한 이후 코드를 주성하여 다시 github repository 에 반영해야 하는 경우가 있다.
[Github 와 연동하기 : https://technote.kr/352]
코드 반영은 Flow는 다음과 같다.
1) 코드 수정
2) [Ctrl + Shit + `] 을 눌러서 teminal 을 실행시킨 후 수정 코드 실행해서 에러 유무 확인
3) 문제가 없을 경우 왼쪽 세번째 아이콘 선택
4) 자동으로 수정된 파일들이 탐지되고, 상단에 수정 내용 작성한 후 "V" 아이콘 선택하여 commit 생성 (git commit)
5) 하단에 push 가능한 commit 의 수가 나오고 해당 버튼 누르면 github repository 로 push 진행 (git push)
첫 push 시 아래와 같은 popup 발생
6) 첫 push 시 vscode에서 반영하고자 하는 github repository 에 push 권한 여부 확인이 필요하여 아래와 같은 절차가 진행됨
7) 일련의 과정들이 진행되고 하면 하단에 commit 가능한 숫자가 사라진 것을 확인할 수 있음.
8) Github repository 에 가보면 수정한 파일이 push 되어 있음을 확인할 수 있음.
TroubleShooting
1) 자신의 repository 가 아닌 타 repository 에 반영시 권한이 없을 경우 아래와 같은 에러가 발생할 수 있다.
예> technotekr 이 TechNoteCode 가 생성한 repository 에 반영을 시도하였을 경우
Git: remote: Permission to TechNoteCode/Sample.git denied to technotekr.
[상세 Git error log]
> git pull --tags origin master
> git ls-files --stage -- D:\GithubCode\Sample\test.py
> git cat-file -s 29977e7f62693b29697d057e9b23e51f56d6df94
> git show :test.py
> git ls-files --stage -- D:\GithubCode\Sample\test.py
From https://github.com/TechNoteCode/Sample
* branch master -> FETCH_HEAD
> git push origin master:master
> git cat-file -s 29977e7f62693b29697d057e9b23e51f56d6df94
> git show :test.py
> git ls-files --stage -- D:\GithubCode\Sample\test.py
> git cat-file -s 29977e7f62693b29697d057e9b23e51f56d6df94
remote: Permission to TechNoteCode/Sample.git denied to technotekr.
fatal: unable to access 'https://github.com/TechNoteCode/Sample.git/': The requested URL returned error: 403