00tim00
    • 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 簡介 :::spoiler 學到什麼 [課程: 尚硅谷Git入门到精通全套教程](https://www.bilibili.com/video/BV1vy4y1s7k6?p=2&vd_source=9b07773fad148ac20789df7ac559e4b7) ![image](https://hackmd.io/_uploads/HkDZ2Km46.png) ::: * git 是分布式的版本控制管理工具 * 體積小、快 * [官網](https://git-scm.com/) ## git 架構 * 工作區 -> 暫存區&ensp;->&ensp;本地庫 -> 上傳網路 &ensp;&ensp;&ensp;&ensp;&ensp;&ensp;add&ensp;&ensp;&ensp;&ensp;&ensp;commit ## git 命令 | 常用指令 | 作用 | | -------- | -------- | |git config --global user.name name|設置用戶名| |git config --global user.email abc@gmail.com|設置用戶簽名| |git init|初始化本地庫| |git status|查看本地庫狀態| |git add (file name)|添加文件至暫存區| |git commit -m "日誌訊息" file name|提交本地庫| |git reflog|查看歷史紀錄| |git reset --hard (版本號)|版本穿梭| ### git init git init 預設分支為master (最右邊藍色的master) no commit yet: 沒有東西提交到本地庫 notihing to commit: 暫存區沒有東西 ![image](https://hackmd.io/_uploads/rkgYqFEET.png) ### 創建一個文件後 多了unpacked file: 尚未追蹤文件(尚未添加到暫存區),文件只從在工作區 文件檔名是紅色的 ![image](https://hackmd.io/_uploads/rymRnYN4p.png) ### git add git 會幫我們把CRLF(window format)換成LF (linux format)換行符號 檔案放在暫存區(git 開始追蹤),標示為綠色的,這樣才可以commit **git rm --cached (file name):** 檔案從暫存區移除 (工作區仍然存在) ![image](https://hackmd.io/_uploads/rkr9pYVNT.png) ### git commit 提交到本地庫,**生成版本日誌** git commit -m "日誌訊息" file name working tree clean: 所有東西都提交了 ![image](https://hackmd.io/_uploads/Hk5MkcENp.png) ### git reflog 簡短的版本訊息 (前7位的版本訊息) 指針指到哪一個就是當前版本 ![image](https://hackmd.io/_uploads/Syqd15VVT.png) ### git log 查看版本完整訊息(詳細版本號) ![image](https://hackmd.io/_uploads/HJPsJ5N4T.png) ### 第二次提交文件 我在第一行新增了文字 但git 是用行為單位去做維護的 所以顯示為刪除一行,新增一行 ![image](https://hackmd.io/_uploads/BJhclqNNa.png) 文件夾中指看的到當前版本的樣子 ![image](https://hackmd.io/_uploads/r1HqW9NET.png) ### git reset --hard (版本號) 文件變舊版本的文件 (Hello git 後面的東西不見了) git reflog(版本紀錄),會記錄moving 到哪 ![image](https://hackmd.io/_uploads/rkrjGq4Vp.png) 指針指向的分支 (現在是master) .git/HEAD ![image](https://hackmd.io/_uploads/B1Sf7qE4a.png) .git/refs/heads master 指真是master -> 當前的版本號 寫的是當前的版本號 ![image](https://hackmd.io/_uploads/H1TSmcNE6.png) ## git 分支 * 開發時可以把工作從主線上分離出來 * 所以開發的時候**不會影響到主線的運作** * 簡單理解可是看成複本,但git是透過pointer實現 * 創建、查看、切換、合併 | 指令 | 作用 | | -------- | -------- | |git branch 分支名|創見分支| |git branch -v|查看分支| |git checkout 分支名|切換分支| |git merge 分支名|把指定的分支合併到當前的分支上| ### git branch 還是在master ![image](https://hackmd.io/_uploads/B1j7toENa.png) ### git chechout 此時文件夾的資料就是hot-fiz 裡面的資料 ![image](https://hackmd.io/_uploads/HJjUFj4Vp.png) branch 不會被移除 ![image](https://hackmd.io/_uploads/H1PasoE4T.png) ### git merge (正常合併)() * 要回到master這樣merge才會是合併到master分支上 hot-fiz的內容合併(更新)到master上 ![image](https://hackmd.io/_uploads/ryMBoj44T.png) ### git merge (衝突合併) (兩邊都修改,git不知道如何更新) * 創建分支後,兩邊都做了修改就會出現衝突 (修改後要提交才有用) git status 會顯示合併失敗,和master後面會出現merging ![image](https://hackmd.io/_uploads/BJ8lJ34N6.png) 此時hello.txt 下面會講哪裡conflict,要手動挑整 ![image](https://hackmd.io/_uploads/rkzaJh4ET.png) 挑整完再提交(commit)檔案 :::danger 注意: commit 後面不能加檔案名 ::: 此時fot-fiz的內容不會被修改 ![image](https://hackmd.io/_uploads/rJvkZ34Va.png) ## git 團隊協作 * push, pull, clone, fork ### 團隊內合作 * 要有管理員管理權限(同團隊) * A ->(push) 代碼託管中心 ->(clone) B(modify, merge) * B ->(push) 代碼託管中心 ->(pull) A pull 同步code ### 跨團隊合作 * C去改A的代碼(C和A為不同的團隊) * fork: 複製到我的代碼託管中心 * C的代碼託管中心 ->(fork) C(modify, merge) * C ->(push) C的代碼託管中心 -> pull requst (C對A發出) * A審核後merge進A的代碼託管中心 -> (pull) A, B ## GitHub * 遠程帶碼託管中心 創建別名 (就不用打網址了) | 常用指令 | 作用 | | -------- | -------- | |git remote -v|列出全部別名| |git remote add (別名) (網址)|設置網址別名| |git push (別名、網址) (分支)| push 進遠程庫| |git pull (別名) (分支)|更新本地的版本(同步 本地庫和遠程庫的資料)| |git clone (網址)|複製到本地庫| * push 會有權限的問題,所以要在github setting 中manage access 決定誰可以提交程式碼 * clone 是可以不需要登入帳號的(取決於權限) * 提取代碼 * 自動初始化 * 創建別名 (git remote -v)看: 通常是orgin * windows 登入透過登入憑證管理帳戶 * 更新本地的版本(同步 本地庫和遠程庫的資料) * git pull (別名) (分支) ## IDEA * 在IDE中會有很多IDE建立專案時會出現的文件,所以要用git中的```git.ignore```去忽略上傳,就可避免IDE衝突 * 在到```git.config```去把位置寫上去 * 要注意windows 的path 是```\```,在git中要改成```/``` ``` [core] excludesfile </git.ignore path> ``` ## GitLab ## 快捷鍵 ### linux 快捷鍵 * ctrl + L: 清除畫面 * cat (file name): 查看檔案 * tail -n (N) (file name): 查看最後N行 ### vim 快捷鍵 * i 進入編輯狀態 * yy 複製 (要先ESC 退出編輯狀態) * p 貼上 * shift: 輸入command * wq: 保存退出 ## reference * [課程: 尚硅谷Git入门到精通全套教程](https://www.bilibili.com/video/BV1vy4y1s7k6? * https://hackmd.io/@howhow/git_with_vscode#git-%E7%B5%90%E5%90%88-vscode-%E7%AF%84%E4%BE%8B

    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