Yu-Ting Chen
    • 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

      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
    • 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

    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
    # Git & github 重點筆記 內容包含 Git & github 重點筆記與 [GIT101] Git 超新手入門 課程回顧 ###### tags: `MTR-Note` `MTR-Course` ## 重點筆記 ### 概念說明 * git 是什麼? * git 是一種進行版本控制的工具 * 讓使用者可以清楚知道不同版本間的差異,並且可以回到不同版本的狀態 * Repository 數據/版本庫 * 版本狀態: * untracked * unmodified * modified * staged * 說明:新加入的檔案會是 untracked 狀態,使用 git add 以後,會變成 modified,git commit 以後,才會變成 staged 狀態。而原先即存在於資料夾底下的檔案若在兩次 commit 之間都沒有更動,則屬於 unmodified 狀態 * branch 分支 * commit 一個版本 * git 的階層關係:repo(一整個專案) -> branch(其中一條分支) -> commit(一個版本) ### git 基本操作 * git init * 初始化,在欲進行版本控制之資料夾底下輸入git init,進行初始化 * 若欲去除版本控制,可使用rm -r .git * git status * 查看版本控制狀態 * git add * 決定是否將檔案加入版本控制 * git add filename * git add . (將現在所在資料夾的所有檔案都加入版本控制) * 後悔加入可使用:git rm --cached filename * git commit -m "leave message" * 加入版本控制 * 將add的檔案確實加入,變更版本狀態為staged * git commit -am"leave message" * 將修改過的檔案(狀態為modified),一併commit * 注意:新加入的檔案,還是必須先使用git add * git commit --amend * 可修改 commit message * git log * 檢視commit紀錄 * git log --oneline,可檢視較短的紀錄 * git checkout * 切換版本 * git checkout +版本號,可回到該版本狀態 * git checkout master,可回到最新版本狀態 * git checkout --filename,可回到修改前狀態(僅限於未 commit 之前的檔案) * .gitignore * 可將不想放入版本控制的檔案加入,例如帳號密碼或系統設定檔 * touch .gitignore * 將檔案名稱寫入 .gitignore * git diff * 可以看到在上次commit和這次commit之間修改過什麼檔案 * git reset * commit 可是後悔了,可以使用 git reset 回到還沒 commit 之前 * 指令:git reset HEAD^ * 有三種模式可選:soft、mixed、hard,預設值是 mixed,下指令時可不必附註模式。[看更多了解三種模式差異](https://ithelp.ithome.com.tw/articles/10187303) ### git branch 操作 * git branch NewBranchName * 開一條新的 branch * git branch -v * 看現在的branch有哪些 * git chechout -b * 新開一條 branch,並切換到新的 branch 上 * git chechout -b branchname * git branch -d branch_name * 刪除舊的branch * git checkout branch_name * 切換branch * 也可以直接使用遠端的 branch * git merge branch_name * 在(master上)把 branch_name 合併進 master * conflict * 當branch要合併,系統偵測發現檔案有衝突(兩條線改到同一個部分,需手動解決衝突,解決後會新增一個commit) * 使用 git status 查看衝突部分再修改 * git branch -m * 若 branch 名稱打錯,可透過此指令修改名稱 * git branch -m newname ### github 操作 * [如何將 code 上傳到 GitHub?](https://gitbook.tw/chapters/github/push-to-github.html) * 新增 new repo * 按照指令: * git remote add origin+url * git push -u origin master * git push * 把檔案上傳到 github 更新 * git push origin master * git push origin branchname * git pull * 把 github 上更新的檔案同步至本地端 * git pull origin master * git clone * 把 github 上的 repo 複製一份至本地端 * git clone +url * pull request(在 github 上點選) * 在 github 上要求 merge * github pages * 可在 setting 中找 github pages,選擇啟用 * github flow * 協作流程:新開一個branch,新增或進行改動、commit,完成後 git push 到遠端,發 pull request,確認沒問題後,將 branch merge 後。在本地端的master,git pull origin master,隨後即可刪除已經被合併的 branch。 * 交作業與同步流程也一樣,細節可參考[我的這份筆記](https://hackmd.io/LLgC45OHQxWA9sYJDbab9g?both) * hook:發生某事時通知我,可以用來檢查程式碼是否符合規範...等。 ## 對應 Lidemy 課程:[GIT101] Git 超新手入門 課程大綱 ### 在開始學習 Git 前的預備知識 1. 什麼是版本控制? 2. 如何安裝 Git ### 看穿 Git 的把戲 1. 其實都一樣啦:從資料夾到 Git 2. 一元復始:git init 3. 你還好嗎:git status 4. 選我選我選我:git add 5. 把你寫進我的故事裡:git commit 6. 歷史紀錄一目了然:git log 7. 想回到過去:git checkout 8. 不重要的邊緣人:.gitignore 9. Git 基本指令複習 ### Git 的平行時空:branch 1. 為什麼我們需要 branch? 2. 一眼看穿 branch 3. 給我一個新的宇宙:git branch 4. 跨越宇宙:git checkout 5. 當兩個宇宙合併:git merge 6. 當世界崩蹋:conflict ### GitHub:全球最大工程師交友平台 1. 我跟 Git 到底什麼關係? 2. GitHub 導覽:視覺化的 repository 3. 如何把 code 放上 GitHub 4. 我就是潮流:git push 5. 跟隨潮流:git pull 6. 抓到你了:git clone 7. GitHub 整合實戰 8. 免費的網頁空間:GitHub Pages 9. 工程師之間的協作:GitHub Flow 10. GitHub 的死對頭們:GitLab 與 Bitbucket ### Git 狀況劇 1. 我 commit 了但是想改 commit message 2. 我 commit 了可是我又不想 commit 了 3. 我還沒 commit,但我改的東西我不想要了 4. 我想改 branch 的名字 5. 想摘下遠端的 branch 給你 ### 客製化各個階段:Git hook 1. hook 是什麼? 2. Git hook 簡介加簡單示範 ### 總結 ## 其他學習資源 - [kdchang:Git 與 Github 版本控制基本指令與操作入門教學](https://blog.techbridge.cc/2018/01/17/learning-programming-and-coding-with-python-git-and-github-tutorial/) - [GitHub Guides](https://guides.github.com) - [高見龍:為你自己學 git](https://gitbook.tw) - [Will 保哥:30 天精通 Git 版本控管](https://github.com/doggy8088/Learn-Git-in-30-days/blob/master/zh-tw/README.md) - [連猴子都能懂的 Git 入門指南](https://backlog.com/git-tutorial/tw/intro/intro2_1.html) - [git 官網](https://git-scm.com)

    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