GitHub

Published by onesixx on

์ดˆ๋ณด๋ฅผ ์œ„ํ•œ ์ฑ… : https://git-scm.com/book/ko/v2
์–„์ฝ” ์ƒ: https://youtu.be/FXDjmsiv8fI ํ•˜ https://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
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x