Skip to content

Instantly share code, notes, and snippets.

@hyunjun
Last active May 6, 2021 05:57
Show Gist options
  • Save hyunjun/d61a173e6b81c603ab02 to your computer and use it in GitHub Desktop.
Save hyunjun/d61a173e6b81c603ab02 to your computer and use it in GitHub Desktop.
git remote add & fetch
  • github

  • pull request

    $ git remote add [remote name] git@github.[some_company].com:[id]/[repository_to_fork].git
    $ git checkout -b [branch name] [remote name]/[remote branch name]
    $ (some work)
    $ git push
    
    # pull request from github.[some_company].com
    
  • push directly

    $ git clone git@github.somecompany.com:[id]/[repository name].git # git clone forked repo
    $ cd [repository name]
    $ git branch -a
    $ git branch -a
    * master
      remotes/origin/HEAD -> origin/master
      ...
    $ git remote add --track [source branch name] [remote name] git@github.somecompany.com:[source id]/[repository name].git
    $ git fetch [remote name]
    $ git checkout -b [my branch name] [source id]/[source branch name]
    $ git branch -a
    * [my branch name]
      master
      remotes/[source id]/[source branch name]
      remotes/origin/HEAD -> origin/master
      ...
    $ git push
    
  • 상황: iris의 dialog-management, iris-email에 대해 ag-steward-svc 계정에서 자동으로 bapi client scala를 upgrade하는 PR이 만들어짐
  • 문제점
    • bapi client scala version이 upgrade되면서 기존의 class Booking에 default value가 없는 새로운 parameter 2개 추가, compile error 발생
    • 만들어진 PR은 ag-steward-svc 계정이 fork한 repo에서 만든거라, 내 계정으로는 그냥 해당 branch로 switch가 안됨
  • 해결
    • git remote add ag-steward-svc git@github.agodadev.io:ag-steward-svc/dialog-management-1.git
    • git fetch ag-steward-svc
    • git checkout --track ag-steward-svc/update/bookingapi-client-scala-0.17.0
      • branch name이 ag-steward-svc:update/bookingapi-client-scala-0.17.0으로 만들어져있는데 checkout할 때는 colon을 /로 변경해야 함
      • comment의 screenshot 참조
    • compile 오류 해결
    • git switch -c <branch name>으로 내 계정에서 새로운 branch 생성
    • git push --set-upstream origin <branch name>으로 PR 만들고 이후 작업 진행
@hyunjun
Copy link
Author

hyunjun commented May 6, 2021

Screenshot 2021-05-06 at 13 56 14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment