劉杰
    • 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
      • Invitee
    • 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
    • Engagement control
    • 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 Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control 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
Invitee
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
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Git & GitHub Crash Course For Beginners --- tags: git relate --- ###### tags: `git` # GIT是甚麼 * VCS(Version Control System)追蹤電腦檔案的改變 * 分散式版本控制(去中央化版本控制) Distributed version control > 代表專案的開發者們不需要在同一個網路環境下完成 * 2005年被Linus Torvalds創造也是Linux的創造者 * JAVA PYTHON Static html node.js c#....都能使用它,它只是單純儲存檔案 * 隨時都能回朔檔案只要有其他時期儲存的commits * 有使用者端以及遠端的存在 # GIT的概念 * 追蹤code的歷史紀錄 * 為你的檔案做簡潔的紀錄 * commit就是"簡潔的紀錄"並且可以在任意時候完成 * 可以造訪那些commit在任意時候 * 在commit之前可以有一個前置階段 # 安裝GIT Mac http://git-scm.com/download/mac Windows http://git-scm.com/download/win # 指令 ## 基本指令 `git init` // 啟動一個本地端的Git檔案夾 - 當要操作任何檔案之前都要做這個動作 `git add<file>` // 加入檔案到Index裡面 `git add .` // 加入全部檔案到Index裡面 `git rm --cashed <file>` // 刪除git add的狀態 `git status` // 確認檔案狀況從整個工作樹中(Working Tree) - 這裡是commit之前的一個前置階段 `git commit -m"file"` // commit `git push` // 把檔案推到遠端的檔案夾(如Github) `git pull` // 從遠端把最新的檔案抓下來 `git clone` // 把遠端的檔案複製下來目前本機端要使用的檔案夾內 `git rm --cashed <file>` // # 實際專案操作 首先設立一個資料夾並且選git bash here ![](https://i.imgur.com/2wufyAV.png) 就可以看到會直接連結到這個資料夾的位置 ![](https://i.imgur.com/ut0UI5H.png) `touch` index.html, app.js ![](https://i.imgur.com/urCbII6.png) `git init` 啟用這個資料夾 ![](https://i.imgur.com/HhoZRia.png) 會多一個.git 資料夾出現 ![](https://i.imgur.com/3AxGzqP.png) ## git自機版本存檔操作 建立一個檔案 hello.txt `git status` 查看狀態 會有剛剛加入的文件名稱並且顯示紅字 ![](https://i.imgur.com/jOWrDeS.jpg) --- 這時候使用 `git add .` 加入資料夾內所有的檔案加入追蹤 通常輸入成功會沒有東西出現就是好事,有出錯的話會有錯誤訊息顯示 再次輸入 `git status` 查看狀態 這個時候會顯示剛剛加入的文件名稱並且變成綠色 ![](https://i.imgur.com/lpZRx4r.jpg) --- 接著輸入 `git commit -m "add new file hello.txt"` 存檔的概念(版本紀錄) ![](https://i.imgur.com/MCrXkbm.jpg) 再次輸入 `git status` 確認內容 ![](https://i.imgur.com/zQitUFx.jpg) 到這個階段剛剛的新的文件存上去存檔的地方摟! ## 註冊github以及把檔案推上去 https://github.com/ 接下來就是正常的註冊流程,推薦先不要開啟二階段認證會造成比較多麻煩 下一步就是要開啟新的Repository,它就是在Github上最主要的運作單位 在your repositories 的頁面下找到 NEW 新增後會進入 ![](https://i.imgur.com/cmLoaj6.png) 通常填完Repository之後 點擊Create Repository ### 上傳本機端的資料上傳到雲端 這個時候要先從CMD確認說有無連結雲端: ![](https://i.imgur.com/96pTucw.png) 這時候看到的空白代表雲端是沒有關聯的遠端空間,所以下一步我們就開始做連結 ![](https://i.imgur.com/2Bo6Unw.png) ps. 大部分會用origin做遠端的名字是個習慣,但其實可以自己取都行 下一步到剛剛your repositories 上面尋找上面尋找這裡點下HTTPS後複製這段網址並貼回去上面 ![](https://i.imgur.com/zItM0W7.png) ![](https://i.imgur.com/A1G0ffL.png) 如果是第一次連結它會需要你做一些認證輸入帳號密碼名稱等等 這個時候再查詢一次做 git remote -v 這個時候會顯示這個 ![](https://i.imgur.com/6NU4JaK.png) fetch 以及 push 左邊那串網址代表我們上傳以及我們下載檔案的雲端網址非常重要 ### git push 把檔案推上雲端 當我們要把檔案存到雲端上面的時候我們會使用這個指令, `git push origin(雲端名稱) master(分支名稱)` ![](https://i.imgur.com/TVqeZLG.png) 推上去檔案之後雲端就會有連接到的檔案 ![](https://i.imgur.com/pX2Xi8X.png) 在這個介面下就可以看到每次建立的commit紀錄非常方便! ## 安裝SourceTree 下載網址 https://sourcetreeapp.com/ 因為Windows不像Mac 系統可以使用 stree . 這個指令叫出程式 可以從 File 的地方開啟待會要作業的檔案的資料夾 ![](https://i.imgur.com/AgB5S10.png) 就可以從這邊看到剛剛檔案的編輯紀錄 ![](https://i.imgur.com/ESeQnMN.png) # git的工作流程圖 ![](https://i.imgur.com/StCQLji.png) ![](https://i.imgur.com/LcfUBpn.png) # 其他學習資源 https://gitbook.tw/ https://ihower.tw/git/index.html https://github.com/doggy8088/Learn-Git-in-30-days?fbclid=IwAR2tU7V7kmvVJJgZVJpyHu8ACiJPk7vifaQCKULHKCUrp7OUJwT8HeQy_j4 https://backlog.com/git-tutorial/tw/intro/intro1_1.html

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