GitHub Main에 나와있는 Repository의 Description은 Readme.md과는 다른 설정을 해야한다.

 

해당 Repository에서 About의 톱니바퀴를 클릭하면

 

Description에서 설정할 수 있으며, readme.md 파일과는 달리 Github Main에서 해당 Repository에 대한 짧은 소개를 남길 수 있다.

 

 

추가적으로 Website를 입력할 경우, Repository 내에서 관련된 링크를 공유할 수 있다.

'DevOps > Github' 카테고리의 다른 글

[Github] Issue 작성하기  (0) 2023.10.02
[Github] Commit 후 Contribution Graph에 기록되지 않을 경우  (1) 2023.10.01
[Github] Rename a Folder  (0) 2023.01.15

1. Git bash에서 remote repository 변경 전 pull을 통해 버전 맞추기

$ git pull origin main
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 9 (delta 6), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (9/9), 2.10 KiB | 46.00 KiB/s, done.
From https://github.com/HJ0216/TIL
 * branch            main       -> FETCH_HEAD
   1843ac3..8797bb6  main       -> origin/main
Updating 1843ac3..8797bb6
Fast-forward
 README.md | 3 +++
 1 file changed, 3 insertions(+)

 

 

2. remote repository 내 불필요한 파일 제거

$ git rm --cached -r test.txt
rm 'test.txt'

# remote repository 내 불필요한 test.txt 파일 제거

 

폴더 제거 시,

git rm --cached -r 폴더명

# rm: remove
# --cached: 원격 저장소의 폴더 또는 파일 삭제 옵션
# --cached가 없을 경우, 로컬 저장소의 폴더 또는 파일도 삭제
# -r: directory 옵션

 

파일 제거 시,

git rm --cached -r 파일명
git rm --cached 파일명

# 둘 중 택 1
# -r 옵션은 폴더를 지울 때는 필수, 파일을 지울 때는 선택

 

 

3. 버전 관리를 위한 commit 진행

$ git commit -m "remove a test.txt"
[main 759bd78] remove a test.txt
 1 file changed, 1 deletion(-)
 delete mode 100644 test.txt

 

 

4. 원격 저장소로 push

$ git push -u origin main
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 223 bytes | 223.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/HJ0216/TIL.git
   8797bb6..759bd78  main -> main
branch 'main' set up to track 'origin/main'.

 

 

➕ --cached를 입력하지 않았을 때, remote repository와 local repository

1. 임의 파일(will_be_deleted.txt) 생성

2. git bash에서 add, commit, push 진행

$ git add /c/git_total/will_be_deleted.txt


$ git commit -m "add a test file for git pratice"
[main ed8b4a2] add a test file for git pratice
 1 file changed, 1 insertion(+)
 create mode 100644 will_be_deleted.txt


$ git push -u origin main
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 340 bytes | 340.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/HJ0216/TIL.git
   567d81d..ed8b4a2  main -> main
branch 'main' set up to track 'origin/main'.

3. remote repository에서 push 내용 확인

4. git bash에서 --cached 제외하고 파일 remove 진행

$ git rm will_be_deleted.txt
rm 'will_be_deleted.txt'

$ git commit -m "remove a test file for git pratice"
[main 95467dc] remove a test file for git pratice
 1 file changed, 1 deletion(-)
 delete mode 100644 will_be_deleted.txt

$ git push -u origin main
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 231 bytes | 231.00 KiB/s, done.
Total 2 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/HJ0216/TIL.git
   ed8b4a2..95467dc  main -> main
branch 'main' set up to track 'origin/main'.

5. remote repository 및 local repository에서 push 내용 확인

 

 

 

참고 자료

📑 [git] github에 잘못 올라간 폴더 및 파일 삭제하기

 

발생 Error

Git Bash에서 다음 명령어를 입력할 경우,

$ git pull origin main
remote: Enumerating objects: 247, done.
remote: Counting objects: 100% (247/247), done.
remote: Compressing objects: 100% (187/187), done.
remote: Total 247 (delta 73), reused 157 (delta 38), pack-reused 0
Receiving objects: 100% (247/247), 59.49 KiB | 378.00 KiB/s, done.
Resolving deltas: 100% (73/73), done.
From https://github.com/HJ0216/TIL
 * branch            main       -> FETCH_HEAD
 * [new branch]      main       -> origin/main

fatal: refusing to merge unrelated histories

fatal: refusing to merge unrelated histories

Error 발생

 

 

Error 원인

pull 명령어는 fetch와 merge를 한 번에 처리하는 명령어인데, merge가 되지 않는 상황

(fetch: 원격 저장소 내용 가져오기, merge: 로컬 저장소의 내용과 원격 저장소의 내용 병합하기)

 

push 명령은 로컬 저장소의 commit log와 원격 저장소의 commit log를 보고, 원격 저장소의 마지막 commit id와 동일한 commit id를 가진 로컬 저장소의 commit 시점을 찾아낸 뒤, 원격 저장소의 마지막 commit과 연결

 

commit histories가 서로 관련이 없을 경우, 즉 공통된 commit 지점이 존재하지 않을 경우, merge할 수 없음

 

 

해결 방법

1. git clone 명령어를 통해 원격 저장소 복제

2. pull 명령어 + 옵션을 통해 merge 진행

$ git pull origin main --allow-unrelated-histories
From https://github.com/HJ0216/TIL
 * branch            main       -> FETCH_HEAD
Merge made by the 'ort' strategy.
 AI/ann_model.py                   |  65 +++++++++++++++++
 AI/dacon_seoul_ddarung.py         | 103 ++++++++++++++++++++++++++
 AI/data_shape.py                  |  90 +++++++++++++++++++++++
 AI/evaluate_and_predict.py        |  51 +++++++++++++
 AI/hyperParameter_Tuning.py       |  40 ++++++++++
 AI/indicator_with_california.py   |  61 ++++++++++++++++
 AI/mae_and_mse.py                 |  48 ++++++++++++
 AI/matplotlib_plot2.py            |  44 +++++++++++
 AI/matplotlib_scatter_and_plot.py |  81 +++++++++++++++++++++
 AI/missing_value_handling.py      | 149 ++++++++++++++++++++++++++++++++++++++
 AI/multiLayer_Perceptron.py       |  74 +++++++++++++++++++
 AI/r2_score.py                    |  64 ++++++++++++++++
 AI/rmse_def.py                    |  63 ++++++++++++++++
 AI/split_train_test1.py           |  51 +++++++++++++
 AI/split_train_test2.py           |  58 +++++++++++++++
 AI/split_train_test3.py           |  68 +++++++++++++++++
 AI/useful_method_from_numpy.py    |  18 +++++
 README.md                         |  68 +++++++++++++++++
 18 files changed, 1196 insertions(+)
 create mode 100644 AI/ann_model.py
 create mode 100644 AI/dacon_seoul_ddarung.py
 create mode 100644 AI/data_shape.py
 create mode 100644 AI/evaluate_and_predict.py
 create mode 100644 AI/hyperParameter_Tuning.py
 create mode 100644 AI/indicator_with_california.py
 create mode 100644 AI/mae_and_mse.py
 create mode 100644 AI/matplotlib_plot2.py
 create mode 100644 AI/matplotlib_scatter_and_plot.py
 create mode 100644 AI/missing_value_handling.py
 create mode 100644 AI/multiLayer_Perceptron.py
 create mode 100644 AI/r2_score.py
 create mode 100644 AI/rmse_def.py
 create mode 100644 AI/split_train_test1.py
 create mode 100644 AI/split_train_test2.py
 create mode 100644 AI/split_train_test3.py
 create mode 100644 AI/useful_method_from_numpy.py
 create mode 100644 README.md

➕ git pull 명령어

origin: remote repository의 URL short name

main: main branch의 remote repository

 

 

이후, push 재 진행

$ git push -u origin main
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 520 bytes | 520.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/HJ0216/TIL.git
   5376d70..1843ac3  main -> main
branch 'main' set up to track 'origin/main'.

 

필요없는 Branch 제거

$ git push origin --delete master
To https://github.com/HJ0216/TIL.git
 - [deleted]         master

 

 

 

참고 자료

📑 fetch, 원격 저장소의 데이터를 로컬에 가져오기만 하기

📑 git push, pull (fatal: refusing to merge unrelated histories) 에러

📑 git branch 삭제

📑 git pull, push와 origin의 의미

 

$ git push -u origin main
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 520 bytes | 520.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/HJ0216/TIL.git
   5376d70..1843ac3  main -> main
branch 'main' set up to track 'origin/main'.

1. Git 홈페이지에서 사양에 맞는 Git Download

 

2. 모든 내용을 Default로 진행하되,

"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'

(참조: [해결 방법] error: failed to push some refs to 'https://github.com/')

 

기존 원격 저장소에 저장되어있는 버전과 원격 저장소와 연동시킨 로컬 저장소의 버전이 맞지 않을 경우, 발생하는 문제로 원격저장소 내용을 로컬 저장소에 pull을 진행시킨 후 push를 진행

 

 

필요없는 Branch 삭제

$ git push origin --delete master
To https://github.com/HJ0216/TIL.git
 - [deleted]         master

 

 

 

참고 자료

📑 git username 확인, 변경

📑 Git 최초 설정: 사용자 이름과 이메일 설정하는 방법

 

발생 Error

Git Bash에서 다음 명령어를 입력할 경우,

$ 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'

! [rejected]        main -> main (fetch first)
⭐ error: failed to push some refs to 'https://github.com/HJ0216/TIL.git'

Error 발생

 

 

Error 원인

원격 저장소의 main branch에 저장되어있는 내용과 로컬 저장소의 내용이 일치하지 않아 발생

 

 

해결 방법

원격 저장소 내용을 로컬 저장소에 먼저 pull 시킴

$ git pull origin main
remote: Enumerating objects: 247, done.
remote: Counting objects: 100% (247/247), done.
remote: Compressing objects: 100% (187/187), done.
remote: Total 247 (delta 73), reused 157 (delta 38), pack-reused 0
Receiving objects: 100% (247/247), 59.49 KiB | 378.00 KiB/s, done.
Resolving deltas: 100% (73/73), done.
From https://github.com/HJ0216/TIL
 * branch            main       -> FETCH_HEAD
 * [new branch]      main       -> origin/main
fatal: refusing to merge unrelated histories

 

 

⚠️ 추가 문제: fatal: refusing to merge unrelated histories Error 발생

(참조: [해결 방법] fatal: refusing to merge unrelated histories)

 

 

 

참고 자료

📑[GitHub] Repository에 'main' branch로 push 하기