[GIT/GITHUB] git 기초

자두·2021년 10월 3일
0

GIT-GITHUB

목록 보기
1/5
post-thumbnail

CH1. git 기초

1. git start

init

$ mkdir [dir-name]
$ cd [dir-name]
$ git init
$ git remote add [remote-name] [git-repo-address]
$ git branch -M [branch]  # master->main
~~ 작업 중 ~~
$ git add [commit할 files]
$ git commit
$ git push -u [remote-name] [branch]

clone

$ git clone [git-repo-address]
~~ 작업 중 ~~
$ git add [commit할 files]
$ git commit
$ git push [remote] [branch]

2. git code

branch rename

바꿀 브랜치 위치에서

$ git branch -M [바꿀 브랜치 명]

create remote

$ git remote add [remote-name] [git-repo-address]

first push

$ git push -u [remote] [branch]

-u 옵션 추가로 async 맞춰줄 수 있음

remote directory

$ rm -rf directory

check all files in any directory

$ git status -uall

NOTICE

1. git add

  • 현재 업데이트 된 파일 전부(.)를 추가하는 것보단 파일 하나하나를 써가며 추가하는 것이 바람직

2. git commit

  • commit은 되도록 작동가능한 최소 단위, 기능별로 분할해 하는 것이 좋음
  • commit message는 한글보다는 영어로 작성하는 것을 지향
  • commit message 작성 시, 앞 부분에 prefix를 달아주면 기능별 분류가 되기때문에 가독성이 좋아짐
    ✔ prefix EX ⬇
    feat: features		// 기능개발
    docs: documentations	// 문서작성
    conf: configurations	// 환경설정
    test: test			// test 관련
    refactor: refactoring	// 유지보수
    fix: bug-fix		// 오류 수정

3. license

  • license를 꼭 확인해야 함
  • license EX ⬇
    mit license - 모든 행동에 제약이 없음
    apache - 제약은 없으나, apache의 소유권 주장
    gnu - gpl를 조금이라도 사용 시, gpl

3. .gitignore

  • .gitignore에 작성된 파일은 git에 올라가지 않음

4. branch

create new branch

$ git branch [new-branch-name]

switch branch

$ git checkout(or switch) [branch]

merge

$ git merge [merge branch]

conflict

$ vi [conflict-file]

$ git add [conflict-file]

$ git commit

vim error - swp

$ rm [file].swp

profile
블로그 이사했어요 https://ktmihs.tistory.com/

0개의 댓글