GitHub

Published by onesixx on

초보를 위한 책 : https://git-scm.com/book/ko/v2
얄코 상: https://youtu.be/FXDjmsiv8fIhttps://youtu.be/GaKjTjwcKQo

인증토큰 (2020.07)

이제부터 인증은 Token으로

권한지정후 Token생성, 생성후 권한변경 가능

<Clone> > [ add > commit > push ]

Git 저장구조와 명령어에 따른 트랜잭션

<brankch>:가상의 작업공간 와 <checkout> :코드뭉치버리기

Remote 이름은 origin

  1. local Brach는 main (=master)
  2. remote Branch 도 main (=master)

checkout : 마지막 commit으로 되돌아가기

Discard hunk, Discard changes

Merge : branch병합

https://learngitbranching.js.org/?locale=ko

현재작업하는 공간(head branch)

설치

brew install git git-lfs
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global core.precomposeunicode true
git config --global core.quotepath false
git config -l

credential.helper=osxkeychain
user.name=sixx
[email protected]
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
core.precomposeunicode=true
core.quotepath=false

git 명령어 -옵션

GitHub 사용
~$➜ git init

 git config 명령어를 통해 설정정보를 저장할 수 있다.

~$➜ git config --list

~$➜ git config --global core.editor "code --wait"  # vscode로 editor변경
~$➜ git config --global user.name "sixxchung"
~$➜ git config --global user.email "이메일주소"
~$➜ git config --global core.autocrlf input   # for mac
~$➜ git config --global core.autocrlf true    # for window

~$➜ git config --global -e
hint: Waiting for your editor to close the file...

GitHub은  Git(분산 버전관리툴)을 사용하는 프로젝트를 지원하는 웹호스팅 서비스

  • 개인 공간으로 활용할 수 있는 유상 서비스
  • 오픈소스를 위한 무상 서비스

Git으로 자신의 코드를 관리하고 있다면, GitHub에 해당 코드를 올려놓고 어디서든 수정가능하며,
다른 사람들이 내 코드에 pull-request를 보낼수도 있다.

git add *
git commit -m "some init msg"

이제 branch 이름이 master가 아닌 main으로 사용하도록 권고하고 있다.

~$➜ git branch -M main

orgin은 원격서버를 나타내고, main은 로컬의 Branch명이다.

git remote add origin https://github.com/sixxchung/dam.git
git push -u origin main

pull-add-commit-push

/git$ git clone https://github.com/sixxchung/dam.git
/git$ cd dam
/git$ cd /git/dam
/git/dam$ git stauts

/git/dam$ git pull
/git/dam$ git add .
/git/dam$ git commit -m "commmmment
/git/dam$ git push
root@273bd20cb55e:/workspace/git# cd edulab
root@273bd20cb55e:/workspace/git/edulab# git pull
Username for 'https://github.com': sixxchung
Password for 'https://[email protected]': 
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 3 (delta 2), reused 3 (delta 2), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/sixxchung/edulab
   f5e2bb1..376228e  main       -> origin/main
Updating f5e2bb1..376228e
Fast-forward
 README.md | 1 +
 1 file changed, 1 insertion(+)

root@273bd20cb55e:/workspace/git/edulab# git add .
root@273bd20cb55e:/workspace/git/edulab# git commit -m "0604"
[main 7a888f7] 0604
 14 files changed, 19805 insertions(+), 1 deletion(-)
 create mode 100644 .ipynb_checkpoints/3-checkpoint.ipynb
 create mode 100644 .ipynb_checkpoints/3-checkpoint.py
 create mode 100644 .ipynb_checkpoints/Untitled1-checkpoint.ipynb
 create mode 100644 .ipynb_checkpoints/Untitled2-checkpoint.ipynb
 create mode 100644 .ipynb_checkpoints/global_a-checkpoint.ipynb
 create mode 100644 .ipynb_checkpoints/global_a-checkpoint.py
 create mode 100644 3.ipynb
 create mode 100644 Untitled1.ipynb
 create mode 100644 Untitled2.ipynb
 create mode 100644 __pycache__/global_a.cpython-36.pyc
 create mode 100644 global_a.ipynb
 create mode 100644 global_a.py
 create mode 100644 submission_xgb1.csv
root@273bd20cb55e:/workspace/git/edulab# git push
Username for 'https://github.com': sixxchung
Password for 'https://[email protected]': 
Counting objects: 15, done.
Delta compression using up to 256 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (15/15), 162.79 KiB | 6.51 MiB/s, done.
Total 15 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), completed with 1 local object.
To https://github.com/sixxchung/edulab.git
   376228e..7a888f7  main -> main

암호 저장

# Pull하기전에 아래 코드를 실행 시키고,  
git config --global credential.helper store

git pull
#Username
#Password

https://amkorousagi-money.tistory.com/entry/Git-personal-access-token

GitHub Collaborator 추가하기

Push권한은 프로젝트 관리자와 Collaborator만이 가진다.

생성한 프로젝트에서 Setting > Collaborators > Add collaborator > 이메일 추가

추가된 Collaborator(협력자)는 프로젝트에 업로드(Push)/다운로드(Pull) 권한을 부여받음.

ERROR

error: Your local changes to the following files would be overwritten by merge:

commit 하거나 stash 하라
원격저장소의 내용으로 덮어 씌우는 경우가 많아서

$ git stash
$ git pull

error: The following untracked working tree files would be overwritten by merge:

$ git add -A     # git add .   # git add * 
$ git stash
$ git pull

로컬에서 untracked files을 clear한다.
워킹 디렉토리 안의 추적하고 있지 않은 모든 파일을 지우게 되고, 복원이 안됨

$ git clean  -d  -f .

여기서, -d (전체 디렉토리 삭제)는 아래 옵션으로 대체가능하다.

  • -x  : Git이 모르는 파일뿐만아니라, ignored files 까지 삭제
  • -d : untracked files뿐만아니라 untracked directories 까지 삭제
  • -f : 강제 run

Missing or invalid credentials. Error: socket hang up

remote: No anonymous write access. fatal: Authentication failed for

미리 github의 access tokens을 받아 저장해 둔다.

~ $ vi .git-credentials

https://sixxchung:[email protected]
$ git config --global credential.helper store

fatal: unable to access : The requested URL returned error: 403

https://beagle-dev.tistory.com/244

Pushing to https://github.com/sixxchung/adminlte.git

remote: Permission to sixxchung/adminlte.git denied to sixxchung.

fatal: unable to access ‘https://github.com/sixxchung/adminlte.git/’: The requested URL returned error: 403

Completed with errors, see above

Push할때, 해당주소에 대한 권한이 없기 때문에, 403 에러 발생


1. 인증하기

  • =) git remote set-url origin “https://[email protected]/sixxchung/adminlte.git” 를 입력해주세요
  • =) 여기에서 github-username 에는 본인이 github 에서 사용하는 username 을 적으시면 되고 github-repository-name 에는 git reposit 이름을 입력하시면되요. “” 큰따음표는 제거하시구요.
  • =) 제일 처음에 git remote add origin git_reposit_주소.git 을 통해 origin 명칭을 만들었지만 해당 주소에 대한 권한이 없어서 푸쉬를 할 때 에러가 난거에요.


2. 소스코드 푸쉬하기

  • =) 터미널에서 git push -u origin master 를 입력합니다
  • =) 깃헙 패스워드 입력을 하라는 창이 나오고 입력을 하시면 본인의 깃주소에 소스코드가 올라갑니다.
  • =) 인증이 끝난 후부터는 git push만 하면 기존의 세팅한 주소로 바로 푸쉬가 됩니다. 변경을 원하시면 git remote “set-url” “any_name” “git_reposit_주소”를 사용하시면 되요

100MB

https://iambeginnerdeveloper.tistory.com/entry/github-%EC%97%90%EB%9F%AC-%ED%95%B4%EA%B2%B0%ED%95%98%EA%B8%B0-remote-error-this-exceeds-GitHubs-file-size-limit-of-10000-MB-%EB%8C%80%EC%9A%A9%EB%9F%89-%ED%8C%8C%EC%9D%BC-push

please clean your repository working tree before checkout

https://yourtime.kr/entry/깃허브-사용-시-please-clean-your-repository-working-tree-before-checkout-에러-해결-방법 

 워킹 트리 정리

다시금 pull로 땡겨오는 것 

git stash
git pull

Categories: Ubuntu

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x