이미 설치 된지 확인
$ git
```qgu
2. Download git !
*깃 다운로드!*
```bash
w install git
(If u want to use different emails for each project, delete –global)
현재 로컬 저장소의 사용자 등록
(만약 프로젝트마다 다른 이메일 사용하고 싶으면 –global 지워버렷)
$ git config [--global] user.name “Shaun Koh”
$ git config [--global] user.email email_id@email_domain.com
깃 설정 확인
$ git config --list
퍼블릭 키 존재 여부 확인
$ cat ~/.ssh/id_rsa.pub
디렉토리 없으면 퍼블릭키 생성
$ ssh-keygen
(press enter three times for public key)
(엔터 세번 눌러줌)
$ cat ~/.ssh/id_rsa.pub
키 클립보드에 복사
$ pbcopy < ~/.ssh/id_rsa.pub
깃허브 세팅 -> SSH and GPG keys -> new SSH key 에 내 퍼블릭 키 추가
reference: https://help.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh
TODO FROM HERE —-
Change directory (cd) into working dir
Initialize git
$ git init .
$ ls -al
Creating Version
Working Tree <-> Starting Area <-> Repository
Repository: where versions are saved // .git directory
버전 저장되는 곳
Staging Area: Files that are staged for version
저장소에 staging 할 파일들 있는곳
Working Tree: Currently working files that are not staged for version
현재 작업중인, staging 안될 파일들 있는곳
$ git status
$ git add <filename>
$ git commit -m “message 1”
$ git commit
$ git commit -am “version 2” // untracked files cannot be processed. i.e., new files must be added before at least once with ‘git add ‘
$ git log
$ git log --stat
/* Version difference */
// Show difference
$ git diff
// Delete changes in ORIGINAL file into previous version
$ git reset --hard
// Show patch log
$ git log -p
Checkout : converting version
controls HEAD’s ptr
// master === latest version
$ git log
// Go back to previous version —> does not erase
$ git checkout <commit_id from git log>
// Go back to latest version again
$ git checkout master
Version Deletion
RESET
:control nch that HEAD points
e.g. reset master // means chang nch’s version to master’s version
e.g. reset version // chang nch’s version to specific version and unlink(delete) specific version’s post-versions
$ git reset --hard <commit_id>
$ git reset --soft <commit_id>
Revert
revert without deleting version: stays in git log
MUST BE reverted from top to down ONE BY ONE
$ git revert <commit_id>
## NCH : multiple operation in one repo
$ gi
nch // * master
$ git log --all --graph --oneline // (HEAD -> master) work 3
$ gi
nch
nch_name]
$ gi
nch // * master apple —> * means curren
nch
$ git log --all --graph --oneline // (HEAD -> master, apple) work 3 —> HEAD-> means curren
nch
base nch a — merge commit
___ master ___/
$ git checkout master
$ git merge
nch_a]
<<<<<<<<< HEAD
content 1
==========
content 2
>>>>>>>>
nch a
here | base | there | 2-way | 3-way |
---|---|---|---|---|
A | A | A | A | A |
H | B | B | conflict | H |
C | C | T | conflict | T |
H | D | T | conflict | conflict |
Download the latest .dmg package for Mac Link: [Meld for OSX][meldlink] [meldlink]: https://github.com/yousseb/meld/releases/ “go meld”
$ sudo vim ~/.gitconfig
[diff]
tool = meld
[difftool]
prompt = false
[difftool "meld"]
trustExitCode = true
cmd = open -W -a Meld --args \"$LOCAL\" \"$PWD/$REMOTE\"
[merge]
tool = meld
[mergetool]
prompt = false
[mergetool "meld"]
trustExitCode = true
cmd = open -W -a Meld --args --auto-merge \"$PWD/$LOCAL\" \"$PWD/$BASE\" \"$PWD/$REMOTE\" --output=\"$PWD/$MERGED\"
$ git difftool
$ git mergetool
$ git remote add origin https://github.com/kohpaul/learn_git.git
$ git remote
$ git push
$ git push --set-upstream origin master
$ git push -u origin master
create a new repository on the command line echo “# self_learn” » README.md git init git add README.md git commit -m “first commit” git remote add origin https://github.com/kohpaul/self_learn.git git push -u origin master
…or push an existing repository from the command line git remote add origin https://github.com/kohpaul/self_learn.git git push -u origin master
References:
https://opentutorials.org/course/3837
https://opentutorials.org/course/3839
https://opentutorials.org/course/3840
https://opentutorials.org/course/3841