기본적인 git 사용방법은 튜토리얼[1]을 통해서 공부하였습니다.

git basic 명령어

  1. git config/init/clone
    git config –-global user.name “[name]”
    git init [repository name]
    git clone [url]
  2. git add/commit [6]
    git add [file], git add *, git add .
    git commit -m “[ Type in the commit message]", git commit -a
  3. git reset/revert [7]
    git reset --soft HEAD~, git reset [--mixed], git --hard HEAD~
    git reset file.txt == git reset [--mixed] HEAD file.txt
    git revert HEAD~3, git revert -n HEAD~5 HEAD~3
  4. git branch/checkout
    git branch <branchname>, git branch release_1.0 master
    git branch -D <branchname>, git branch -m <branch1> <branch2>
    git checkout <branch>, git checkout -b <branch> -t <base_branch>
  5. git remote/push/pull/fetch
    git remote -v, git remote add upstream https~~~
    git push origin, git push origin master:master, git push --set-upstream origin develop
    git fetch origin, git fetch origin master:master
    git pull origin, git fetch origin master:master
  6. git merge/rebase/cherry-pick [8]
    git merge <branch>, git merge --squash <branch>
    git rebase <branch>, git rebase -i <branch>
    git rebase <base_branch> <topic_branc>, git rebase --onto master server client
    git cherry-pick <commit>

협업 방법

git을 활용한 협업 방법(workflow)에는 Git flow, GitHub flow, GitLab flow가 있습니다.
나온 순서로는 Git flow > GitHub flow > GitLab flow, 복잡도는 Git flow > GitLab flow > GitHub flow 순입니다.\

  1. Fork: upstream -> origin
  2. clone: origin -> local
  3. issue 생성: in upstream
  4. branch 생성: in local
  • git checkout -b develop -t origin/develop
  • git checkout -b feature-add_world -t develop
  1. git commit: git commit -ma “” or 5.1 git add 5.2 git commit -m
  2. git push origin
  3. pull request(PR) (with issue 번호) origin => upstream
  4. code review 8.1 pull request 후, 해당 branch에 추가 commit/push되면, PR이 자동 update됨
  5. merge: in upstream
  6. update local from upstream
  • git checkout master
  • git fetch upstream
  • git rebase upstream/master
  • git push -f origin master

git flow

Reference