Yu-Tong Judy
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    10
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 理解如何在Github使用Pull Request (PR) tags: `Github` `git clone` `git pull` `Pull Request` `codeshiba` ## 學習重點 1. ``git clone`` 完整複製他人專案到自己電腦 2. 建立與切換 branch 3. 設定 upstream 4. 發送 Pull Request 請求合併 5. ``git pull`` 更新既有專案狀態至最新 6. ``clone``和``pull``差別在哪 7. 總結 Pull Request 的流程 8. 為什麼需要透過 Pull Request 來開發 ### 1.``git clone`` 完整複製他人專案到自己電腦 - 找到想要複製的專案頁面,這邊複製的是「mentor-program-2nd」 - 點擊「code」,選擇「SSH」,複製「git@.....」整串指令並貼至終端機內。這樣就能把整個專案內容複製一份到本機,且存在同名的目錄裡。 ![](https://i.imgur.com/YhAdxRc.jpg) > [高見龍:這裡指的「內容」不是只有檔案,而是指所有整個專案的歷史紀錄、分支、標籤等內容都會複製一份下來。](https://gitbook.tw/chapters/github/clone-repository.html) - 下載回來後,可以看到同名的目錄,以及目前處於``main``分支。 ![](https://i.imgur.com/xod8ieJ.jpg) ### 2. 建立與切換 branch - 新增名為「judy-mission-19」的分支,在終端機中輸入``git branch judy-mission-19`` ![](https://i.imgur.com/z0rlgxb.jpg) - 輸入``git branch``查看,確實已成功建立分支 ![](https://i.imgur.com/rHNjpLj.jpg) (按鍵盤``q``離開) - 輸入``git checkout judy-mission-19``從「main」切換至「judy-mission-19」分支 ![](https://i.imgur.com/kVlEnUd.jpg) - 在此分支之下,新增名為「judy」的資料夾,並於其中再新增「mission19」資料夾,在資料夾內新增檔案。 ![](https://i.imgur.com/v2kjTzf.jpg) - 輸入指令``git add .``把所有異動加入工作目錄索引之中。 - 輸入指令``git commit -m "add description.md"``在字串中說明異動內容,並把異動提交到本機端儲存庫中。(這裡我說明自己新增了一個名為「description」的md檔) - 可以輸入指令``git status``檢查目前為止的狀態,查看有沒有什麼異動漏掉提交的。如果已經是最新狀態,就會顯示「working tree clean」 ![](https://i.imgur.com/ScNIpPX.jpg) ### 3. 設定 upstream - 輸入指令``git push``把所有修改推上Github專案中 - 這邊git跳出錯誤提示,告知遠端並沒有相對應名稱的分支,git會不知道要推去給誰,指示我們``push``的同時需在遠端伺服器那邊也新增一個同名的分支作為上游(upstream)。 ![](https://i.imgur.com/ToqqrFy.jpg) - 複製git給的指令 ``git push --set-upstream origin judy-mission-19`` 貼上再執行一次。 > [高見龍:設定 upstream 是什麼意思](https://gitbook.tw/chapters/github/push-to-github.html) - 顯示成功``push``上去。 ![](https://i.imgur.com/lluUdru.jpg) ### 4. 發送 Pull Request 請求合併 到Github「mentor-program-2nd」專案頁面,點擊「New pull request」,比較「judy-mission-19」這個分支內所做的事情,與原本的「main」分支的差異。請原作者審核是否接受並``merge``。 點擊右上角綠色鍵 ![](https://i.imgur.com/gLmxtQt.jpg) 選擇要compare的分支名稱 ![](https://i.imgur.com/BEhoO72.jpg) PR頁面 ![](https://i.imgur.com/0M4i96b.jpg) 可以在Pull Request列表中看到剛才提交的PR ![](https://i.imgur.com/mjhQoe1.jpg) ### 5. ``git pull`` 更新既有專案狀態至最新 團隊裡面的大家各自發了新的PR給專案管理者,經過merge之後,則此時專案內容已經跟我當初``clone``下來的不同,因此需要下``git pull``指令,把遠端最新狀態拉下來,更新至本機端。 之後若要再發新的PR,一樣是要再新創一個branch,切換分支,然後才去進行後續的異動。 ### 6. ``clone``和``pull``差別在哪 **git clone** 首次把別人的專案完整內容,下載到自己的本機端,是從無到有的過程。 **git pull** 則是已經下載回來的專案,更新至與遠端線上版狀態相同。也就是說本機端這邊,必須有一個既存專案,才會用``pull``去更新它。 ### 7. 總結 Pull Request 的流程 基本上就是 * clone專案下來至本機端 * 建立新branch並切換到新branch * 進行修改與commit * push上去Github * 發PR去比較新branch與main這個原本branch之間的差異,附上敘述告知專案管理者我做了什麼,管理者再審核是否接受這些修改並``merge``到「main」分支之中。 > [高見龍的文章教學還有多一個前置步驟「fork」](https://gitbook.tw/chapters/github/pull-request.html) > 是先把別人的專案「fork」到自己的Github帳號底下,才從自己帳號去「clone」到本機端。但「mentor-program-2nd」沒有開放「fork」功能,所以我省去「fork」步驟,直接把專案「clone」到我的本機。 ### 8. 為什麼需要透過 Pull Request 來開發 使用PR來進行專案的狀態修正與維護,能保障專案不會因為團隊成員中的任何一人,做了某項修改以後就直接覆蓋掉別人的貢獻。所有的異動提交,最終會由專案管理者審核接受與否,避免出錯。就是一種大家提出意見,主席最終裁定與彙整的概念。 而且PR的相關紀錄,團隊成員彼此都看得到,也能在上面進行修改討論,有助於開發互動。

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully