Lou
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Git 學習筆記 ###### tags: `Git` [TOC] 位於索引中的檔案 : Tracked files(追蹤的檔案) 不再索引內的檔案 : Untracked files(未被追蹤的檔案) > - working tree 是工作目錄 > - 只要 **被索引中的檔案內容** 跟 **工作目錄中的檔案內容**<span style="color:red;">**一致**</span> > 就會被稱為一個 "_Stage_"狀態 > - 只要 **被索引中的檔案內容** 跟 **工作目錄中的檔案內容**<span style="color:red;">**不一致**</span> > 就會被稱為一個 "_Unstage_"狀態 > <br> ![](https://i.imgur.com/xFkkXIE.jpg) Command: **git** - `-m` = message - `init` = 建立 - `add` = 加入 GIT 索引 - `rm` = 刪除 - `status` = 看目前狀態 #### git diff _顯示差異_ - `HEAD` = 比對變更與目前最新版的變更差異 - `-cached` = 索引裡的變更與本地儲存庫最新的變更差異 - `--binary` = 比對二進位檔案差異 - `--name-only` = 比對工作目錄檔案,列出檔案名稱 - `--name-status` = 列出工作目錄及索引之間有多少檔案是被異動的 > git diff 'src-commit' 'tgt-commit' commit 與 commit 比較差異 > git diff 'commit' 與目標 commit 差異 #### git reset _重置索引_ - `-p` = 選取索引中的那些變更有哪些內容要從索引中移除 - `HEAD` = 重置索引及分支(加 ~1 是恢復前一版本,以此類推) - `--mixed` = 重置 HEAD 及索引(預設值) - `--hard` = 重置 HEAD,索引及工作目錄 - `--hard ORIG_HEAD` = 回復前版本(永遠回復 reset 之前的版本) #### git revert _還原歷史上的版本,做相反的 commit_ - `-h` = help 列出功能 - `--abort` = 取消 - `--continue` = 繼續 - `--quit` = 停止 #### git clone _下載遠端儲存庫_ > git clone --no-checkout 'URL' 'Filename' 會以 filename 為主並且不做 checkout > git clone --bare 'url' 把儲存庫的本身下載下來 #### git log _看紀錄_ - `--oneline` = 短的 log 版本 - `--oneline --graph` = log 版本+線圖可加 "-數字" 以顯示筆數 > git log --oneline --graph --all -10 全部的歷史資料取 10 筆 #### git reflog _會記錄工作目錄底下做過的每一次的版控紀錄_ #### git checkout _取出/取回_ - `-- 'name'` = 從索引裡面把 name 檔案的內容整個複製回工作目錄 - `--orphan` = 建立全新分支且沒有 parents > checkout -b "Filename" 可以新增分支後切換 #### git switch _切換分支_ #### git clean _清除工作目錄_ - `-f` = 強制刪除 - `-d` = 刪除整個工作目錄 - `-x` = 執行清除任務,並忽略.gitignore 設定 - `-n` = 看那些檔案會被清除 #### git stash _暫存工作目錄的變更_ - `save 'message'` = 暫存 - `pop` = 取回暫存 #### git branch _查看分支/新增分支_ - `-d` = 刪除分支(只能刪除已經合併的分支) - `-D` = 強制刪除分支 - `-r` = 列出所有遠端追蹤分支 - `-a` = 列出所有遠端+本地分支 > git branch --merged 列出所有已合併過的分支 > git branch --no-merged 列出所有未合併過的分支 > git branch --merged | egrep -v "(^\*|master|develop)" | xargs git branch -d 刪除所有已合併過的分支(CMD/Powershell 不可用) #### git merge _合併分支_ - `--ff` = 快轉合併(預設) - `--no-ff` = 非快轉合併 - `--ff-only` = 僅有快轉合併 - `--no-commit` = 不提交的合併 - `--abort` = 放棄合併 - `--squash` = 壓縮後合併(不可以與關閉快轉機制一起使用,且不會有合併線圖出現) > git merge --no-ff --no-commit 'branchName' 合併可以不 commit #### git rebase 'commit_id' _重訂基底合併_ - `-i` - `--continue` = 繼續 - `--skip` = - `--abort` = 取消 #### git cherry-pick _正向挑選合併_ - `--continue` = 繼續 - `--quit` = 停止 - `--abort` = 取消 #### git push _推送至遠端_ - `--all` = 全部分支推送 > git push -u origin master 將本地分支(master)與遠端分支(origin)建立連結 > git push origin --delete 'branchName' 刪除遠端分支(要先把本地刪除) #### git fetch _將遠端儲存庫的變更下載回來_ - `--prune` 將遠端已刪除的分支剪除 #### git pull _將遠端儲存庫拉下來_ > pull = git fetch + git merge > git pull --rebase = git fetch + git rebase #### git remote _遠端_ - `-v` = 列出網址 - `-h` = remote 的 help - `set-url` = 更改網址 > git remote set-url origin 'new url' 將舊網址改成新網址 #### git commit _建立版本_ #### git apply _套用版本(進版)_ - `--check` = 確認檔案 - `--reverse` = 退版(簡寫-R) <br> <hr> #### git config _GIT 的設定_ > 加上 --global 可以設定 - `core.quotepath` = 改 false 可顯示中文 - `core.editor` = 查看目前編輯器 > git 只能顯示 ASCII 的字元 - git bash 以外的環境要改中文 `set LC_ALL=C.UTF-8` > 更改環境變數 (永久儲存) > `setx LC_ALL C.UTF-8` > MAC/Linux > `export LC_ALL=C.UTF-8` ### 衝突問題 顯示訊息: 1. content = 內容衝突 建議用手動合併 ### 參考資料 1. [為自己學 GIT-另一種合併方式(使用 rebase)](https://tinyurl.com/yfgcs498)

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