SmalWriter
    • 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 學習筆記 下載好之後先檢查git 版本 git -v 本機端儲存 - working directory - staging area - local repository 遠端儲存 - remote repository 1. 先用cd一層一層的進入到指定資料夾 ==輸入git init== 2. 使資料夾受git版本控制 生成.gitgit 在使用init指令,初始化一個隱藏檔案 可以透過 `git init` 去將一個專案 git 化,變成一個被 Git 追蹤、版本控制的專案。 之後我們會發現資料夾內多了一個 `.git` 目錄。這就是 Git 用來儲存所以版本歷史、變動、分支、標籤、等等資訊的地方。 ![](https://i.imgur.com/ygGmW6L.png) 後面會有一個()介紹你現在所在的分支 目前是在master。 - 檢視git基本設定 git config --list - 設定git name& email git config --global user.name "自己名子" git config --global user.name "Hugo" git config --global user.email "自己email(github註冊email)" git config --global user.email "a0988500558@gmail.com" --- 檢查 git 狀態 查詢當前檔案變動狀態的指令 `git status` git status 把檔案受git控管放到暫存區(三種方式) git add 檔名 git add*.副檔名 git all --all 一次新增所有 `git add .` 只會將新增和修改過的文件添加到暫存區, 而 `git add --all` 則會將新增、修改和刪除的文件全部添加到暫存區。 把檔案放到本機儲存區 -m ""裡面的參數是設定訊息 有寫才知道你變更什麼 git commit -m "message" # 為什麼要 兩次動作 廣場和倉庫? - 倉庫就是你的Repository,小廣場就是Staging Area 逐筆檢查 每筆都add /commit code review - 在 Git 裡,主要可以分成「工作目錄(Working Directory)」、「暫存區(Staging Area)」以及「儲存庫(Repository)」三個區塊,透過不同的 Git 指令,可以把檔案移往不同的區域: - 可以使用 `git add` 指令把檔案加至暫存區(Staging Area),然後可使用 `git commit` 指令把暫存區的內容移往儲存庫(Repository)。 ![](https://i.imgur.com/lv7VOwJ.png) 為什麼要二段式這麼麻煩? ------------ 先 `add` 再 `commit` 這樣二段式感覺可能有點麻煩,但也是有好處的。你可以想像你有一個倉庫,在倉庫門口有個小廣場,這個廣場的概念就像跟暫存區一樣,你把要存放到倉庫的貨物先放到這邊(`git add`),然後等收集的差不多了就可以打開倉庫門,把在廣場上的貨物送進倉庫裡(`git commit`),並且記錄下來這批貨是什麼用途的、誰送來的。 當然,你也可以每來一件貨物就開倉門存一次、紀錄一次,但這樣一來開倉庫的次數就會非常多。老實說這樣也沒什麼過錯,只是因為太過零碎的 Commit,有時候要查閱紀錄可能會有點不太方便;另外,過於零碎的 Commit 也可能給你的同事帶來一些困擾,例如要進行 Code Review 的時候,比較有整理的 Commit 可以一次看到比較完整的內容,而不需要一個一個 Commit 慢慢看。 所以,什麼時候要 Commit? ---------------- 這個問題沒有標準答案,你可以很多檔案修改好再一口氣全部一起 Commit,也可只改一個字就 Commit。常見的 Commit 的時間點有: 1. 完成一個「任務」的時候:不管是大到完成一整個電子商務的金流系統,還是小至只加了一個頁面甚至只是改幾個字,都算是「任務」。 2. 下班的時候:雖然可能還沒完全搞定任務,但至少先 Commit 今天的進度,除了備份之外,也讓公司知道你今天有在努力工作。(然後帶回家繼續苦命的做?) 3. 你想要 Commit 的時候就可以 Commit。 # commit 沒有限制多久commit頻率 - 一個階段 - 每個動作 - 一天至少一次 一次動作add & commit 條件:必須曾經被git控管(什麼意思?)才能同時add /commit git commit -a -m "message" git commit -am "message" # 檢查 git commit 紀錄 git log git log --oneline 精簡版git log Vim 指令 會跳出: 要輸入以下指令才能離開 :q 才能退出 :wq 儲存後退出 先:w 在:q --- 把檔案區的檔案移動到你指定的版本,但檔案會保留 git reset <資訊碼> git oneline 前面七個數字就是資訊碼 - 回覆到上一個commit 的狀態 git reset <資訊碼> --hard - 會把檔案也移除掉(刪除) 檢查歷代版本紀錄 git reflog - 回復reset所做的動作 --- - 先確保master 分之是乾淨的才能創新分之 檢視分支 git branch 新增分支 ``` git branch <new branch name> 像是git branch cat ``` 移動到主分支 git checkout master 移動分支 git checkout cat(移動到cat 這個分支) 刪除分支 確保你不再該分之下 ``` git branch -d <branch name> git branch -D <branch name> 編輯分支名子 git branch -m <old branch name><new branch name> ``` >先git branch cat >再git checkout cat >再git status確認一下有沒有再你要的分支,再確認有沒有清空 --- git flow ----->main | |---dev |--feature 1 |--feature 2... > 通常由組長把功能merge到dev Git flow 提出不同的分支功能,分別有 **master**、**develop** 、**hotfix**、**release**、**feature** 五種分支。 合併分支 ![](https://i.imgur.com/Jq87Vsl.png) git branch -m cat feature(分支名) git branch 確認 git merge feature -m "merge feature" 合併完就能刪除分支 ![](https://i.imgur.com/wKye16w.png) git branch -d feature (分支名) 再打git branch 來確認是否已經已經刪除 --- new 來新增遠端儲存庫 (https) git branch -M main git branch -m main 大小寫M都可以 把master ->main 1.git branch -M main (更改master 名子) 2.git remote add origin 設定遠端路徑https://github.com/SmalWriter/gitapp13.git 把金鑰貼在原本之前,前面再加一個@符號, https://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@github.com/SmalWriter/gitapp13.git `origin` 名子可以自訂義 3.git remote -v 檢視遠端,確認一下 4.git push -u origin main git push origin main 把專案push上去,push到遠端 第一次會要你輸入帳號密碼登入, 接下來指令畫面就會跳轉到 5.add readme.md 或是一開始就勾選 能在這裡介紹和打步驟說明,或是當作章節目錄 詳細解說專案,讓大家知道這個專案在幹什麼 6.add file >create new file .gitignore 表示不被git 控管的檔案 在點commit new file,就建立好.gitignore檔案 * gitignore.io [幫你創建忽略檔案的gitignore](https://www.toptal.com/developers/gitignore) 打標籤名後按enter ,最後在一次按確定,在複製全部進去.gitignore內容裡面 java eclipse maven 7.git pull origin main 把檔案拉下來 readme / .gitignore --- * settings/developer setting/personal access tokens/tokens/classic ![](https://i.imgur.com/xiQgfJp.png) * generate new token/generate new token(classic) 在這邊勾選你要開放給連線用戶的權限,也可以之後在設定 ![](https://i.imgur.com/Q8jkSt0.png) `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` --- 把金鑰貼在原本之前,前面再加一個@符號, https://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@github.com/SmalWriter/gitapp13.git --- ``` git remote set-url origin<url> 讓你連到別人遠端 你能遠端推分支 ``` set-url 是把原本的url 改成新的(不常用) ``` git remote set-url origin https://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@github.com/SmalWriter/gitapp13.git ``` 在來 ``` git remote -v ``` 確認 --- # 步驟 先add 再set 如果add成功就不用set 1.git remote add origin git remote add 你設置的repoName "金鑰+網址" https://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@github.com/frank9478/GymProject.git git remote set-url origin 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@https://github.com/frank9478/GymProject git pull origin master --allow-unrelated-histories git remote -v --- git fetch 抓資料 git pull 包含git fetch --- git 比方說git remote add 的name 按tab 會自動補完 --- windows 以外 才要remote set-url 用token,不然第一次git push 要打帳號密碼 第一次先git remote add name url 之後就git -u name + 資料夾名子 以後push pull 就不用再打分支 git push --set-upstream 分支名稱 git push --set-upstream origin judy-mission-19 ``` git push --set-upstream origin master ``` fork 組長的專案到自己的github --- eclipse 第一次才要匯入專案 之後git pull之後直接覆蓋檔案,就能直接執行 git clone 網址 完整下載遠端的repo 不用再次init code . 在vscode 做編輯 你已經再當前目錄,就只要打code . 不然要打 code + 路徑 **Ctrl + Enter** 提交评论 --- >玟吟 git-repos裡面放所有repo 一個respository(repo)就是一個project 如何建立一個git respository? git init git add <檔案名稱> git add .加這個資料夾的所有檔案 git commit 保存進度,遊戲存檔 進入vim的編輯器 :q! 就可以強制關掉vim了(不存檔) :wq!則是會存檔 commit -m 這個訊息是給自己看的,本身並沒有什麼功能,所以要打什麼都可以。原則上簡單好懂就好 git status只會顯示跟上一次commit不同的部分 在git Create respository git remote add <自訂名稱> <網址> git push -u <remote名稱><branch名稱> 預設就在master

    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