1 minute read

Git key

계정 settings - Developer Settings - Personal access tokens 에서 Tokens (classic) - Generate new token (classic)

user.name and user.email

repository에 push할 때 작업 중인 계정의 정보가 commit에 반영된다.

$ git config --global user.name $name
$ git config --global user.email $email_address

Git fork

원하는 git repository로 가서 fork 버튼을 누르고, 자신의 git repository로 가져온다.

Git clone

git clone $GIT_REPOSITORY_URL

원본 repo -> local repo 최신화

git remote add upstream $ORIGINAL_REPO

git fetch upstream

git checkout master

git merge upstream/master

git push origin master

Branch 관리

git branch

git branch $BRANCH_NAME

git branch -d $BRANCH_NAME

git checkout $BRANCH_NAME

git pull 할 때, please commit your changes or stash them before you merge.

(ws_38) xxxx@oxxxx-xxxx:~/xxxx$ git pull
Password for 'https://xxxxxxx@bitbucket.org':
remote: Enumerating objects: 46, done.
remote: Counting objects: 100% (46/46), done.
remote: Compressing objects: 100% (41/41), done.
remote: Total 41 (delta 29), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (41/41), 7.49 KiB | 958.00 KiB/s, done.
From https://bitbucket.org/xxxx/xxxxxxx
   xx8xx2b..x34a9ex  master     -> origin/master
Updating xx8xx2b..x34a9ex
error: Your local changes to the following files would be overwritten by merge:
        analytics/minimap_visualize.py
Please commit your changes or stash them before you merge.
Aborting
$git pull
^^^ error log

$git stash
Saved working directory and index state WIP on master: 1786b2b ADD: apply auto detect minimap coordinate script

$git pull
Password for 'https://xxxxxxx@bitbucket.org':
Updating xx8xx2b..x34a9ex
Fast-forward
 analytics/crop_inferenced_video.py |  11 ++++++-----
 analytics/get_minimap.py           |  36 ++++++++++++++++++++++++++++++++++--
 analytics/minimap_visualize.py     | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
 analytics/route_minimap.py         |  79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 273 insertions(+), 16 deletions(-)
 create mode xxxxxx analytics/route_minimap.py
 
$git stash pop

git status에서 modified file 되돌리기

git status
modified files:
----

git restore fileName

access request pending issue

깃허브 레포지터리에 관련된 써드파티 툴을 써서 커밋 & 머지를 할 경우,
application access가 없으면 faile이 난다, ‘github access request pending.’

이럴 때는 organization admin이 third-party access에 있는 pending application을 review하고 approval해줘야 한다.

setting

Third-party access

review and approval

reset

commit 잘못했을 때, reset으로 가장 최근 commit으로 돌아갈 수 있음.

git reset --hard HEAD

Categories:

Updated: