ChunTing Lin
    • 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
    # 遊戲可以SL,你的程式也可以!! 簡單Git教學 今日教學都是使用git command不是GUI軟體 在比對程式差異時會使用到vscode ## 前置作業 1. 先去github註冊帳號 (https://github.com/) 2. 下載Git 3. 安裝VSCODE https://code.visualstudio.com/ ## 甚麼是Git VCS (version control system),是一個最多人使用的版本控制系統 常常被程式設計師所使用 詳見Wiki (https://zh.wikipedia.org/wiki/Git) ## 安裝Git https://git-scm.com/download/ 以下是windows的設定 中間有一個設定是選擇編輯器,我是選擇notepad++,你可以選擇你有的文字編輯器 要選擇checkout as it is, commit as unix-style ending (原本是甚麼換行就用甚麼,在commit時使用unix的換行符號來取代windows的換行) 其他選擇預設就好 linux/mac裝好後要設定編輯器 如果要設定編輯器的話 git config core.editor vim (vim i是編輯模式,esc後的離開是:wq) ## 單機版 ### 如何開啟一個專案 建立一個資料夾 `mkdir demo` 切換執行目錄到此資料夾 `cd demo` 起始一個空專案 `git init` ### 建立一些檔案 我使用的編輯器是vscode 再裝好vscode之後 你要切換你的工作目錄 `cd demo` 在當下的目錄(.)開啟vscode `code .` 建立兩個檔案 一個是 ***save.txt*** 另一個是 ***noSave.txt*** ### 觀看git現在狀況 `git status` ### 如何選擇那些東西要存檔 `git add save.txt` `git status` 綠色的就表示被加入暫存區(stage) 如果你要把檔案從stage(綠)變成unstage(紅)的 `git reset` ### 如何存檔 在存檔之前,如果你沒有設定過username跟email的話 他會叫你去設定 `git config user.username 2sdf611097` `git config user.email 2sdf611097@gmail.com` `git commit` commit後,他會跳出你的編輯器 第一行是title 建議內容跟title中間要空一行 寫好後要記得存檔後關閉你的編輯器,git的commit動作才會繼續下去 接下來去修改save.txt 增加個幾行字上去 `git diff` 就可以看到內容的差異 或是使用vscode的功能(左邊第三個圖案) 可以看到兩個版本間的差異 接下來我們使用下面的指令,把所有的檔案一次加入(包含noSave.txt) `git add .` `git commit -m "This is title"` ### 刪除你不要的內容 `git rm noSave.txt` `git commit -m "Remove noSave.txt"` 也可以這樣做 不透過git刪掉你不要的檔案後 在使用`git add -A`把剛剛刪掉的檔案也加入stage內 接著一透過`git commit`把這個動作記錄下來 ### 查看各版本 `git log` 每個版本都會有一個hash(亂碼) 這個hash就代表你的板號 ### 如何切換版本 `git checkout dae2c` (版號要自己透過git log去看,通常打五碼就夠了) 就會看到noSave.txt又出現了 如果要返回主線的話 `git chekcout master` ### 如何建立分支 以遊戲來說,可能有多個選項要選,選了就不能回頭 常見作法就是多存幾個檔案 然後分別去選你要的選項,讓故事繼續下去 在Git內,這樣子就叫做Branch 建立分支 `git branch subBranch` 查看分支 `git branch -a` ### 如何切換分支 建立一個新的分支 `git checkout subBranch` 確認現在在你要的branch上 `git status` 產生一個檔案 `echo 123 > subBranch.txt` 建立一個commit `git add . ` `git commit -m "This is subBranch"` `git log` 回到master `git checkout master` `git log` 會發現他沒有剛剛那個檔案 `git status` ### 如果commit後,後悔了該怎麼辦 #### 修改commit的訊息 `git commit --amend` #### 修改某個commit內的檔案 透過reset到某一個commit版本 `git reset --soft xxxxx` `echo 12345 > save.txt` `git add .` `git commit -m "New commit"` ### 我亂改一通結果東西壞掉了,我想要清掉所有新的改動,回去那個版本 針對所有的檔案的修改 `git reset --hard` 針對單一檔案 `git checkout save.txt` ### 給commit一個可讀的版本名子 看現在有哪些tag `git tag -l` 給當下的commit一個名子:0.0.1 (https://semver.org/) `git tag 0.0.1` 再看一次有哪些tag `git tag -l` ## 多人合作 ### 下載遠端的專案 先到一個你要放這專案的目錄 `cd $HOME` 下載 `git clone https://github.com/2sdf611097/demo-git.git` ### 新增一個commit並且提交到repository 切換目錄到剛剛clone下來的專案 `cd demo-git` `echo "This is first file!!!\n" > newFile.txt` `git add .` `git commit -m "This is first commit"` `git push origin master` ### 別人做了一些更新,我該如何sync到我的local端 下載遠origin端倉庫的master branch到我的local端 並且將git的紀錄以遠端的為主(rebase) `git pull --rebase origin master` ### 如果我更新的東西跟對方改的內容衝突 該怎麼辦 `git pull --rebase origin master` 他說你local端跟遠端不一致,你要解除這些conflict 在編輯器上看到 `<<<<<<< HEAD` 這個是遠端的內容 `>>>>>>> commitMessage` 這個是你的local內容 把這兩個跟==都拿掉 接著把內容改成預期要的樣子後 `git add .` 然後就讓它繼續rebase `git reabse --continue` 這樣就解了一個local端的commit的conflict了,如果你local端有多個commit是遠端沒有的 那就有可能還要再繼續解conflict 如果不想解conflict的話,就要把local端的內容清掉才行 先放棄rebase `git rebase --abort` 把你Local端的東西複製到一個新的branch上 `git branch tmpBanrch` 把master的內容還原到origin/master的local commit `git log` 找對應的commit的hash `git reset --hard xxxxx` 接下來就是pull rebase `git pull --rebase origin master` 因為跟遠端的基底是一致的,所以就不用解ocnflict了 接下來就是自己手動去看差異後,產生新的commit就好 ### 甚麼是origin defaul的倉庫名子就會是origin 這個倉庫是在當初git clone的時候建立出來的 你可以透過 `git remote -v`看現在有哪些倉庫 如果你要新增倉庫的話 `git remote add name xxxx.git` 如果要刪掉的話 `git remote rm name` 接著如果你要Pull或push的時候,就是用這個name去指定是哪個倉庫 ### 重要 在每次做修改之前,要先做pull rebase的動作,確保沒有conflict再繼續 在push之前也要做一樣的事情,把conflict先清除才有辦法Push到遠端倉庫 ## Github介紹 ### 我要怎麼發一個PR ### 問題 1. hash這麼難記,為什麼不都用tag就好 首先是hash是亂數產生的,所以他是絕對的,tag是可以修改的,通常要到指定的commit的話都是用hash,因為同hash他的內容一定依樣,tag是可以改變的,所以兩個人電腦內的同tag是有可能內容不一樣的 大部分的commit都是很小的change,而且該change都有title了,所以不需要都要有tag ### 報到區 1. 冬踏曲密 2. zxc920903 3. markz 4.

    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