"Select Destination Location"에서 경로에 한글이 포함되지 않게 유의
* 문제가 발생하진 않으나 향후 발생할 수 있는 문제를 예방하고자 함
3. Git 설치 후 정상 작동 확인을 위해 Git Bash에
$ git --version
git version 2.39.1.windows.1
입력 후, version 확인
4. user name 및 user email 설정
git config --global user.name "이름"
git config --global user.email "이메일"
# --global: 해당 PC에서 사용하는 모든 git 조작에 적용
git config user.name "이름"
git config user.email "이메일"
# 미지정(local): 해당 저장소에 한해서만 적용
# local이 global보다 우선 적용됨
# user 삭제
git config --unset --global user.name # global user 삭제
git config --unset --global user.email # global user 삭제
git config --unset user.name # local user 삭제
git config --unset user.email # local user 삭제
# user name 변경
git config --global user.name "변경할 이름"
# user 확인
git config --list
⭐ Github와 Git을 연동하기 위해서 Github에 등록된 이메일을 user.email에 설정
5. local PC에 git 저장소 설정
5.1. 폴더 생성
5.2. ⭐ 해당 폴더 내에서 git bash 실행 후, 입력 및 응답 확인
git init
Initialized empty Git repository in C:/git_total/.git/
# local c 폴더의 git_total 폴더를 local 저장소로 지정
6. local PC에 생성한 git 저장소와 원격 저장소 연결
$ git remote add origin https://github.com/HJ0216/TIL.git
# TIL repository와 연동
7. 현재 git 상태 확인
$ git status
On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)
# Branch: master, Commit 대상: 없음
8. Test file Add(커밋할 대상으로 지정한 상태)
$ git add /c/git_total/test.txt
# local c 폴더 안의 git_total 폴더의 test.txt 파일 add
9. 현재 git 상태 확인
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: test.txt
# Branch: Master, Staging: test.txt(add한 파일)
10. commit 진행(변경 사항에 대한 기록을 저장한 상태)
$ git commit -m "Commit Message 입력"
[master (root-commit) 9549c78] using a git bash
1 file changed, 1 insertion(+)
create mode 100644 test.txt
# "Commit Message"와 함께 commit 진행(Commit: 변경사항에 대한 기록 저장)
11. Push 진행(원격저장소에 변경된 내용을 올린 상태)
$ git push origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 229 bytes | 229.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: Create a pull request for 'master' on GitHub by visiting:
remote: https://github.com/HJ0216/TIL/pull/new/master
remote:
To https://github.com/HJ0216/TIL.git
* [new branch] master -> master
# Branch: Master로 TIL repository에 text.txt 파일 저장
⚠️ 문제: [new branch] master -> master
Default Branch인 main Branch가 아닌 master Branch가 새로 생성됨
$ git branch -m master main
# master branch name을 main으로 변경
⚠️ 문제: 변경된 이름의 main branch로 push 진행 시 다음의 오류 발생
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'https://github.com/HJ0216/TIL.git'
$ git push -u origin main
To https://github.com/HJ0216/TIL.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'https://github.com/HJ0216/TIL.git'