[Git] 자주쓰는 git 명령어와 컨벤션

Suyeon·2020년 9월 25일
0

Etc

목록 보기
1/8
post-thumbnail

Git

Config

  • git config —global user.name “suyeon kang”
  • git config —global user.email “tndusrkd91@gmail.com”

Usage

  • git init
  • git remote add origin <repository>
  • git pull origin master
  • git add .
  • git commit -m “”comment”
  • git push origin master

Status

  • git log or git log —online
  • git status
  • git diff

Branch

  • git branch 'name'
  • git checkout 'name'

merge

  • git merge —no-edit text editor 열지 않기
  • git merge 'new branch' (in master branch)

rebase, stash

rebasemerge와 비슷하지만 더 클린한 workflow history를 가질 수 있음
stash는 작업을 임시적으로 어딘가에 저장함(일정 작업이 끝난후에 덮어쓰기 할 수 있음)

  • git rebase master (in new branch)
  • git stash save

Etc

Commit Message 수정

  • git commit --amend -m "New commit message"
  • git push origin branch --force

Commit Message 삭제

  • git reset --hard commitID
  • git push origin branch --force

--soft: History changed, HEAD changed, Working directory is not changed.
reset --hard : History changed, HEAD changed, Working directory is changed with lost data.

remote url 변경

  • git remote set-url origin <new_remote_url>

Convention

Good commit message

simpler version than convention

example

Naming repository

website
http://domain.com -> domain.com.git
http://sub.domain.com -> sub.domain.com.git

others
star-wars.git
the-empire-strikes-back.git
return-of-the-jedi.git

profile
Hello World.

0개의 댓글