NCKU CCP x Titansoft
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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

      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.
      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
    • 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 Help
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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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

    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.
    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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 1/30 Git 教學 ###### tags: `快閃上課` 教學影片:https://youtu.be/8ynlOOKGaVo Git(==分散式版控==)是一種板控系統,也是目前主流的系統 其他的版控系統:TFS(team foundation system) (中央集權版控)、SVN (中央集權版控)、Mercurial ==小提醒==:Git 只適用於**純文字**的版控,並不適用 Word、Power Point 等檔案,若要使用 office 版控,直接按照 **檔案>資訊>版本歷程記錄** 的步驟進行即可~ # 版本控制主要的操作流程 1. **下載git和sourcertree(圖形化操作介面)** 本次上課要用到的兩個東西,安裝sourcetree應該會順便安裝git,如果發現沒有成功的話再額外去下載git。 sourcetree:https://www.sourcetreeapp.com/ git: https://git-scm.com/downloads 確認安裝 git 是否成功,按下 windows+R鍵後搜尋「powershell」(指令視窗)並啟動,然後鍵入指令 `git --version` 確認安裝成功,成功的話會顯示版本號。 在桌面建立一個資料夾,名稱隨意。 (這段操作不一定要透過指令實現,可參考下面的 sourcetree UI 做法) _然後複製該資料夾網址。打開視窗後,鍵入指令 `cd 網址` 切換到該資料夾下。然後鍵入指令 `git init` 初始化以建立能夠被 Git 進行版本控制的環境。_ (圖希望幫助理解上述過程會出現的畫面) ![](https://i.imgur.com/s6tpyDA.png) 記得要把隱藏檔案的選項勾起來,才能夠看見剛剛建立的.git資料夾,之後的版本變更都會被記錄再這裡面。 :::info :information_source: git init 的操作,事實上也可以透過 sourcetree 的圖形化介面來實現哦,不一定要使用終端機指令,可參考下圖。 ::: ![](https://i.imgur.com/QuSfBI6.png) --- 2. **開始版本控制的練習** 開啟sourcetree後,點選上方的add,browse選擇剛剛的資料夾(注意,選到包含有 .git 資料夾的那一層目錄即可,不用選到 .git 資料夾本身) ![](https://i.imgur.com/8iC1mMp.png) 此時在剛剛的資料夾中,建立一個練習用的記事本,並隨意打一些字 之後每當修改記事本的內容後,sourcetree就會顯示變動前(紅色)變動後(綠色)的樣子。 ![](https://i.imgur.com/tbWSYxR.png) 文件修改完後,在Unstaged files的地方會顯示剛剛有修改過的檔案,按下+號,代表你要記錄這次的變更,然後該檔案會被推到上面的Staged files裡 ![](https://i.imgur.com/OMZj9hN.png) 每次變更都**一定**要寫些註解(git 的運作規則),這也是方便自己日後辨認該次變更主要是變了甚麼,再按下右下的commit就完成了。 ![](https://i.imgur.com/1Ezcj4r.png) 接著看一下中間的畫面,經過上述步驟後便產生了新的節點 每次有新的commit(修改),就會產生新的節點,點選節點就可以知道那次的檔案是甚麼樣子,就可以方便自己做版本控制。 ![reference link](https://i.imgur.com/7muWRIP.png) ``` (git 操作補充) * commit|每個事件經由 commit 才會正式紀錄到時間軸中 * reset|退回某一個操作,default 的 soft/mixed 模式會當作該節點到目前節點間的事件都尚未發生(並非從未發生,但如果選擇 hard 的模式看起來就會像是從未發生) * discard|把未 commit 的東西放棄、丟掉(只要未 commit 都可以放棄,請注意放棄就救不回來囉) * revert|新增一個對目標節點「反向操作」的事件節點,對於直接反悔一個節點很方便,通常用於強調「我不要這個操作」 * branch|開啟另一個分支版本,編輯者可在此測試新的方法或是其他改變,原分支並不會因為在新分支上的修改而被改變。sourcetree 有防呆機制,如果當前分支上的 commit 還沒有 merge 回任何分支,sourcetree 會不讓刪除。因此若真的確定要不 merge 就刪除分支內容,需要依照 sourcetree 的提示直接下指令進行 * merge|合併,當前所在的分支是發動點,要選擇把哪個分支 merge 會發動點分支 * conflict|衝突,大家都要 merge 時常發生的事,可能是不同人改到相同的地方,如果不確定要以誰為準,通常要直接找編輯者溝通 * push|檔案推上去 GitHub 或其它遠端 * pull|檔案從 GitHub 或其它遠端拉回來 解決 conflict: 1. 以我為準 2. 以別人為準 3. 去掉檔案中出現的特殊提示符號(`>>>>>>> master` 之類的),把兩人的改變合體 4. 只適合純文字檔案 ``` --- ## 其他操作1:分支功能 在寫程式時,有時會想要額外針對某個部分嘗試不同的寫法,為了不讓嘗試去影響的原本已經寫好的部分,可用「分支(branch)」,彷彿從主幹當中額外長出來的部分。 在希望長出分支的節點滑鼠點一下選取後,按下上方branch按鈕,命名一下後就成功創造分支了。 ![](https://i.imgur.com/WhWIvGd.png) 看一下畫面左側,會顯示分支(BranchTest)和主幹(master),點一下就可以切換,在分支上的版本修改過程就跟上面一樣,故不重述。 ![](https://i.imgur.com/qtyjKVb.png) ## 其他操作2:上傳到github上面 如果你想把的東西上傳到gihub上保存,首先請先建立一組github帳號 網址:https://github.com/ 登入github後,按頭像選 your respositories > 按綠色鈕New > 幫你的respository命名 > 選public/private(看你,然後其他東西不用勾) > 按綠色鈕Create ![](https://i.imgur.com/SHteaEI.png) 接著處理SSH設定,主要是目前上傳東西需要透過SSH協定。 打開剛剛的powershell,鍵入 `ssh-keygen` 不管它一直按enter到結束,產生ssh金鑰。 接著到c槽 > 點user(使用者)資料夾 > 找 .ssh 資料夾 > 打開後用記事本開.pub的檔案(如下) > 複製裡頭全部內容 ![](https://i.imgur.com/m4jaT7k.png) 接著回到github。按頭像選 > setting > 左側點 SSH and GPG keys > 按綠色鈕 Nes SSH Key > 命名,然後把剛剛.pub複製的東西貼到下方 > 按綠色鈕Add SSH key。 ![](https://i.imgur.com/I3vzhz5.png) 回到剛剛創的respository,複製SSH地址(如下) ![](https://i.imgur.com/EorS8af.png) 接著回到sourcetree。 點右上setting > 按 Add > 把default勾起來 > 貼上剛剛複製的SSH地址 > 按OK > 再按OK ![](https://i.imgur.com/ZvrVkFm.png) 最上方工具列 tool > option > 看中間的SSH的部分 > 第一欄選剛剛ssh資料夾的id_rsa(非.pub檔) > 第二個SSH Client 選 OpenSSH > 按OK ![](https://i.imgur.com/KQCAgiG.png) 回到sourcetree主畫面後,最後按下上方push即可上傳,傳完後就可以在github上檢視了。 ``` (補充) Github:放 Git 操作紀錄的空間 對象:個人專案、小程式、開源專案 目的:確保資料不會消失,並提供協作者將程式碼載入編輯、維護 一般公司:GitLab(類似企業版本的 Github)架在自己公司內部的主機 * Quick setup 開一個新的專案(名稱可與原檔名稱不同) * 回到本機端 Git 推上去(Push) * clone|GitHub 檔案複製到本機檔案 * GitHub 自 2021.08.13 後不支援從本機端對遠端使用帳密授權方式連線,一定要使用個人 token (e.g. SSH key) ```

    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

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    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