본문 바로가기
IT/PROGRAM

github 소스 다운 후 git push 에러 해결 . personal access token

by SidePower 2022. 10. 5.

github는 얼마전에 가입은 미리 했지만 오늘 처음 사용하네요.

 

나름대로 git과 github 개념과 명령어는 공부해서 그런지 

github 사이트에서 repository 생성부터

js 파일(test04.js) 등록은 쉽게 진행을 한거 같아요.

내가 공부하고 이해한게 맞는지 나를 검증하기 위해 테스트를 해봤습니다.

 

github에서 js 파일 수정도 해보고 변화를 줘서

히스토리가 잘 쌓이는지도 확인해 봤어요.

 

로컬은 CentOS 리눅스로 정하고

github 사이트에 등록된 repository 전체를 clone으로 내려받았습니다.

전체라지만 test04.js 파일 하나밖에 없어요.ㅋ

 

리눅스에서 js 파일을 수정하고 commit 한 뒤에

github로 push (업로드)하면 리눅스에서 수정한 부분이

github에도 잘 반영되는지 확인해 봤습니다.

 

마지막 push에서 생각지도 못한 에러가 나서 좀 헤맨거 같아요.

자세히 알아볼게요.

 

 git 프로젝트 폴더 만들기
[tmach@localhost ~]$ mkdir git_main
[tmach@localhost ~]$ cd git_main

 git clone으로 github의 repository 다운로드
clone으로 다운 받으면서 github와 리눅스 로컬 git은 정보가 공유됩니다.
[tmach@localhost git_main]$ git clone https://github.com/libero2m/start_tobe.git
Cloning into 'start_tobe'...
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.

[tmach@localhost start_tobe]$ ls -al
total 4
drwxrwxr-x. 3 tmach tmach  35 Dec 28 07:12 .
drwxrwxr-x. 3 tmach tmach  24 Dec 28 07:12 ..
drwxrwxr-x. 8 tmach tmach 163 Dec 28 07:12 .git
-rw-rw-r--. 1 tmach tmach 188 Dec 28 07:12 test04.js

 

 clone을 위한 github의 URL 위치 찾기

해당 repository 메인 화면에 녹색 Code를 클릭하시면

아래처럼 Clone HTTPS 경로가 표시됩니다.

 

 test04.js 파일 변경하기
[tmach@localhost start_tobe]$ vi test04.js

 git 상태 확인
   test04.js 변화를 감지하네요.
[tmach@localhost start_tobe]$ git status
# On branch main
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   test04.js
#
no changes added to commit (use "git add" and/or "git commit -a")

 git add 명령어로 인덱스(스테이지) 등록하기
[tmach@localhost start_tobe]$ git add .

[tmach@localhost start_tobe]$ git status
# On branch main
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   test04.js
#

 git commit . 로컬 repository 반영하기
[tmach@localhost start_tobe]$ git commit -m "linux down comment insrt"

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <tmach@localhost.localdomain>) not allowed
 로컬 git에 사용자 등록을 안해서 오류가 발생합니다. ^^;;

 사용자 등록하기 . github와 동일하게 이메일과 계정 등록
[tmach@localhost start_tobe]$ git config --global user.email "goending2080@gmail.com"
[tmach@localhost start_tobe]$ git config --global user.name "libero2m"

 git commit . 로컬 git의 repository에 최종 반영하기
[tmach@localhost start_tobe]$ git commit -m "linux down comment insrt"
[main 38b109e] linux down comment insrt
 1 file changed, 1 insertion(+)
[tmach@localhost start_tobe]$ git status
# On branch main
# Your branch is ahead of 'origin/main' by 1 commit.
#   (use "git push" to publish your local commits)
#
nothing to commit, working directory clean

 git log . 히스토리 내역 보기
3개의 이력이 있습니다. 
빨간색은 리눅스에서 입력한거고 나머지 두개는 github 사이트에서 한거에요.
[tmach@localhost start_tobe]$ git log
commit 38b109e7f4ff142263d43dfabb371f48a996f737
Author: libero2m <goending2080@gmail.com>
Date:   Tue Dec 28 07:20:30 2021 -0500

    linux down comment insrt

commit 01edfc4381d8664faaaa715f7bd170a976c9f280
Author: libero2m <96155780+libero2m@users.noreply.github.com>
Date:   Tue Dec 28 18:05:17 2021 +0900

    Update test04.js

    comment insert

commit b15e89d5efdc73db4c70f3ea8572c574be7edc80
Author: libero2m <96155780+libero2m@users.noreply.github.com>
Date:   Tue Dec 28 17:54:12 2021 +0900

    Create test04.js

    javaScript_04

 

 github (원격)로 소스 반영하기
[tmach@localhost start_tobe]$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Username for 'https://github.com': libero2m
Password for 'https://libero2m@github.com': 암호입력
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/libero2m/start_tobe.git/'
[tmach@localhost start_tobe]$
 헉...실패 되네요.

오류를 해석하면 

2021년 8월 13일에 암호 인증 지원이 제거되었습니다. 대신 개인 액세스 토큰을 사용하십시오.

 

처음 사용해 보는거라 로그인 방식이 바뀐지 몰랐네요.

개인 엑세스 토큰을 받으러 갈게요.

 

 github에 접속하세요.

우측 상단에 둥근 메뉴를 클릭하세요.

 

 Settings 선택

《Settings》 선택하시면 새로운 화면으로 바뀝니다.

새 화면의 왼쪽 메뉴 중에서 밑으로 내려오셔서 《Developer settings》 선택하세요.

 

 Developer setting

왼쪽의 《personal access tokens》 선택 후에

오른쪽 《Generate new token》 클릭하세요.

 

 New personal access token

Note는 token을 설명할수 있는 적당한 내용을 적으시면 될거에요.

Expiration은 토큰 만료일을 지정하는건데요.

귀찮을거 같아서 만료일 없는 No expiration를 선택했네요.ㅋ

 

No expiration를 선택하니깐

GitHub는 정보를 안전하게 유지하기 위해 토큰의 만료 날짜를

설정할 것을 강력히 권장합니다.

라고 노란색 메시지가 뜨는데요.

참고하세요.

 

 Select scopes

개인 토큰에 부여되는 접근 권한을 지정합니다.

전체 제어(Full control)인 repo를 선택했습니다.

 

 Personal access tokens

생성된 토큰을 복사해 두세요.

 

 

 다시 push 할게요.
     암호 입력에 토큰을 입력하시면 되요.
[tmach@localhost start_tobe]$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Username for 'https://github.com': libero2m
Password for 'https://libero2m@github.com': 토큰입력
Counting objects: 5, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 285 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/libero2m/start_tobe.git
   01edfc4..38b109e  main -> main

 실패 없이 잘 끝난거 같습니다.^^
다시 github 사이트에서 push 잘 처리됐는지 확인해 볼게요.

 

 github 첫화면

기존에 2에서 3 commits로 적용되었습니다.

 

 test04.js 

js파일을 클릭하니 리눅스에서 commit 할때 입력한 설명이 그대로 표시됩니다.

 

감사합니다.

반응형

댓글