12. git work with remote - nephilim/js-git-kata GitHub Wiki

remote info

  • git remote show origin

      Fetch URL: https://github.com/nephilim/temp-to-delete.git
      Push  URL: https://github.com/nephilim/temp-to-delete.git
      HEAD branch: master
      Remote branch:
        master new (next fetch will store in remotes/origin)
      Local ref configured for 'git push':
        master pushes to master (up to date)
    
  • git branch -av

      feature2              39d06ab feature 02 added
      master                9b3ad56 Initial commit
      remotes/origin/HEAD   -> origin/master
      remotes/origin/master 9b3ad56 Initial commit
    

remote + branch

  1. remote + branch
    • track branch
    • pull --rebase

new remote branch(not in local)

  1. git checkout -t origin/feature
    • remote 브랜치를 local로 checkout
      • remote에서 새로 만들어진 브랜치일 경우 git fetch 등이 선행되어야 함
      • 다시 말해, .git/refs/remotes/origin에 존재해야 함(origin일 경우)
    • to local feature branch

new local branch(not in remote)

simple way

  1. github에 project 생성
  2. clone

hard way

  1. github에 project 생성
  2. local에 git 저장소 생성
  3. git remote add origin https://github.com/nephilim/temp-to-delete.git

group remotes

  • git config remote.mygroup 'remote1 remote2 ...'
  • git fetch mygroup