~$
sudo
super user do (관리자 권한으로 실행)
ctrl+c
명령 취소
$
Shell 을 입력할 수 있는 상태라는 의미 $ ls
List Segment $ ls -a
숨김파일까지 보기 $ cd
Change Directory$ cd ..
상위 폴더로 이동 $ mkdir
make directory, 새로운 디렉토리 생성 $ pwd
절대경로 ~
의 의미 알 수 있다 $ touch
새로운 file 생성 $ mv
move 이동mv server.* coffee
: * 서버라는 이름을 가진 모든 확장자명을 옮긴다 *.md
md 확장자를 가지는 모든 파일 $ mv
hello.py ./holla.py 이름 변경시에도 mv 사용 $ ./
현재 경로라는 뜻 $ .filename
파일 이름 앞에 .
붙으면 숨김파일 $ clear
화면 깨끗이 만듦 $ cp
copy 사본 만들기$ rm
remove 파일 삭제$ rm -r
or $ rm -rf
$ vi
파일을 vim으로 열어라$ cat
파일 내용을 확인할 때 사용. 처음 작성한 내용 확인$ python3
or $ python
파이썬 실행 결과 확인: editor vi
기본 normal mode
To edit text, press i
on normal mode
To block text, press v
on normal mode
shift
+;
= :
change to command mode
h
j
k
l
- left, down, up, right i
insert mode v
visual mode ESC
back to normal mode d
delete dd
delete a line / cut Y
yank yy
yank a line p
paste u
undo ctrl
+r
redo a
append A
append from end of line o
open line(under) O
open line(upper) H
move to the top of the screen L
move to the bottom of the screen :q
quit :q!
quit discarding all changes :w
write :wq
write and quit :{number}
jump to {number}th line. = SCM (Source Code Management)
< SCM (Software Configuration Management: 형상관리)
git 설치 확인($ git -v
)
git 환경설정
$ git config --global user.name "당신의유저네임"
$ git config --global user.email "당신의메일주소"
$ git config --global core.editor "vim"
$ git config --global core.pager "cat"
$ git config --list
로 정상 설정 확인 $ vi ~/.gitconfig
에서 수정 가능 Caution: Do not git init on any other directories
./dev 에서
$ git clone URL복사한것붙여넣기
$ git status
$ touch hello.py
→ Untracked file 생김 (red color)ls
$ git add hello.py
→ Changes to be committed: new file : __ (green color)$ git commit hello.py
→ vim editor로 접속됨$ git push origin main
$ git remote
remote address를 보여줌$ git remote -v
remote 상세 address 보여줌$ git push origin main
$ git lg
작업한 log 확인 가능⚠️ commit 할 때,
~~git commit -m~~
가급적 쓰지 말기를 권고
좋은 git 커밋 메시지를 작성하기 위한 7가지 약속 : NHN Cloud Meetup
예시)
feat: Add server.py
fix: Fix Typo server.py
docs: Add README.md, LICENSE
conf: Create .env, .gitignore, dockerfile
BREAKING CHANGE: Drop Support /api/v1
refactor: Refactor user classes
.gitignore 는 git이 파일을 추적할 때, 어떤 파일이나 폴더 등을 추적하지 않도록 명시하기 위해 작성하며, 해당 문서에 작성된 리스트는 수정사항이 발생해도 git이 무시하게 됩니다.
특정 파일 확장자를 무시하거나 이름에 패턴이 존재하는 경우, 또는 특정 디렉토리 아래의 모든 파일을 무시할 수 있습니다.
가장 많이 사용하는 License
Deal with .ipynb
https://www.reviewnb.com
또는 https://github.com/jupyter/nbconvert 으로 .py or .html 로 변환
분기점을 생성하여 독립적으로 코드를 변경할 수 있도록 도와주는 모델
$ git branch
Show available local branch$ git branch -r
Show available remote branch$ git branch -a
Show available All branch$ git branch stem
Create branch (branch name : stem)$ git checkout stem
Checkout branch = $ git switch stem
$ git checkout -b new-stem
Create & Checkout branch$ git commit -a -m 'edit readme.md'
make changes inside readme.md$ git switch main
$ git merge stem
merge branch$ git branch -D stem
delete branch$ git push origin stem
push with specified remote branch$ git diff master stem
see the difference between two branches-u
upstream 표시 해줘야함**$ git push -u origin** stem
- git bash에서 .dev/ 에 팀 깃허브 클론을 만들고 (
$ git clone {팀 깃허브 주소}
)- 클론되서 생성된 'study' directory로 들어감 (
$ cd study
)- 제가 사용할 새로운 branch 생성 (
$ git branch {브랜치명}
)$ git switch {브랜치명}
$ git push -u origin {브랜치명}
$ git mv 기존파일명 변경할파일명
파일 이름 변경됨 (renamed) $ mv 기존파일명 변경할파일명
이렇게 하면 기존 파일은 삭제되고 새 파일 형성된 것으로 인식$ git checkout -- .
or $ git checkout -- {filename}
Undoing$ git rm -f {filename}
Unstaging and Remove$ git commit --amend
Edit latest commit$ git rebase -i <commit>
Edit prior commit$ git rebase --abort
abort rebase$ git rebase --continue
Complete rebase$ git reset HEAD {filename}
Unstaging⚠️ 협업 시, reset은 worst case 이다.
(ex. 직전 3개의 commit을 삭제한 후, remote에 강제 push)
다른 cloned repo에 존재하던 commit log로 인해 파일이 살아나거나, 과거 이력이 깔끔히 사라져 commit log tracking이 힘들어짐.
⇒ solution: 잘못한 이력도 commit으로 박제하고 수정한 이력을 남기자!
👍 Best case: Revert
(ex. 현재 HEAD에서 직전의 3개의 commit을 순서대로 거슬러 올라가 해당 내역에 대해 commit, push 수행)
$ git revert --no-commit HEAD~3..
$ git commit
$ git push origin {branch}
잘못하기 전 과거로 돌아가 최신을 유지하면서 되돌렸다는 이력을 commit으로 남겨 모든 팀원이 이 사항을 공유하고 주지시킬 수 있음.
--no-edit
-m ( $git revert -m {1 or 2} {merge commit id} )
‘tulip’ ,
이렇게 마지막 문장에 콤마를 미리 붙여넣으면, 추후에 내용 추가했을 때 아랫줄에 추가된 줄만 git에서 업데이트 된것으로 뜨기 때문에 이런식으로 작성하는 것이 좋다.