層次數位空間有限公司
    • 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
    **VSCode 連動GitLab ,排除設定檔不進行GIT 連動** - 層次數位客制服務 <img src="https://labspace.com.tw/assets/upload/product//LabSpace-logo-B-03.png" style="float: left; margin-right: 0.5rem;margin-top:-0.3rem; height: 30px;">[LABSPACE](https://shop.labspace.com.tw) --- 要將設定檔推送到 GitLab 上,可以按照以下步驟進行操作。在這裡,我將介紹如何使用 VSCode 進行 Git 操作,以及在 Linux 環境下如何設定推送檔案。 --- ### 1\. **在 Linux 上設定 Git:** 如果還沒安裝 Git,可以用以下命令安裝: ```bash sudo apt update sudo apt install git ``` #### 配置 Git: 在推送檔案前,必須先配置 Git 使用者資訊: ```bash git config --global user.name "你的名字" git config --global user.email "你的電子郵件" ``` #### 初始化 Git 儲存庫: 在你想要推送檔案的目錄中執行以下命令: ```bash cd /path/to/your/project git init ``` #### 設定遠端 GitLab 儲存庫: 添加遠端 GitLab 儲存庫的連結。確保你有一個 GitLab 儲存庫,並複製它的 URL。 ```bash git remote add origin https://gitlab.com/你的帳號/你的儲存庫.git ``` ### 2\. **推送檔案到 GitLab:** #### 將設定檔加入版本控制: 使用 `.gitignore` 文件來排除不必要的檔案,如果你有些檔案不想推送,可以在 `.gitignore` 中進行配置。例如,排除所有的 log 檔案: ```bash *.log ``` 接下來,執行以下命令來將檔案提交到 GitLab: ```bash git add . git commit -m "Initial commit with configuration files" git push -u origin master ``` ### 3\. **在 VSCode 中使用 Git:** VSCode 內建了 Git 支援,可以直接進行操作。 #### 安裝 Git: 首先,確保你已經在 Linux 上安裝了 Git,並且配置了 Git 使用者資訊(如上所述)。 #### 使用 VSCode 的 Git 功能: 1. 在 VSCode 中打開專案資料夾。 2. 點擊左側的**版本控制**圖示(小分支圖標)。 3. 如果你還沒初始化 Git,點擊 "Initialize Repository"。 4. 在設定檔上點擊右鍵,選擇 "Stage Changes" 或者直接點擊 "Stage All Changes"。 5. 輸入提交訊息,然後點擊 "✔️ Commit" 按鈕。 6. 點擊 "Push" 按鈕,將變更推送到遠端 GitLab。 #### 推送到 GitLab: 如果是第一次推送,你需要先設置遠端儲存庫。點擊終端,執行以下命令來添加遠端儲存庫: ```bash git remote add origin https://gitlab.com/你的帳號/你的儲存庫.git ``` 然後在 VSCode 中點擊 "Push"。 ### 4\. **Linux 中的設定檔管理:** 如果你有一些常見的 Linux 設定檔,比如 `~/.bashrc` 或 `~/.vimrc` 想要推送到 GitLab,步驟如下: 1. 將這些檔案複製到你的專案目錄中,例如: ```bash cp ~/.bashrc /path/to/your/project/ cp ~/.vimrc /path/to/your/project/ ``` 2. 然後重複前面的 Git 步驟,將它們提交到 GitLab。 ### 小提示: * 確保你已經在 GitLab 上生成並添加了 SSH 金鑰,這樣推送時不需要輸入帳號和密碼: * 創建 SSH 金鑰: ```bash ssh-keygen -t rsa -b 4096 -C "你的電子郵件" ``` * 複製 SSH 金鑰到 GitLab: ```bash cat ~/.ssh/id_rsa.pub ``` 如果不希望部份檔案如:`db_config.php` 檔案被推送到 GitLab 上,可以使用 `.gitignore` 檔案來排除這個檔案。以下是具體的步驟: ### 1\. **在專案目錄下建立或編輯 `.gitignore` 文件:** * 如果專案目錄中已經有 `.gitignore` 檔案,直接編輯它;如果還沒有,則在專案根目錄中建立一個。 ```bash touch .gitignore ``` ### 2\. **在 `.gitignore` 文件中添加 `db_config.php`:** 在 `.gitignore` 檔案中加入 `db_config.php`,這樣 Git 就會忽略這個檔案,並且不會將它推送到 GitLab: ```bash db_config.php ``` 這樣 `db_config.php` 檔案就不會被添加到版本控制中,也不會被推送到 GitLab。 ### 3\. **如果 `db_config.php` 已經被追蹤:** 如果 `db_config.php` 已經在 Git 版本控制中,你需要將它從 Git 中取消追蹤,並保持檔案在本地存在。執行以下命令: ```bash git rm --cached db_config.php ``` 此命令會將 `db_config.php` 從 Git 的追蹤中移除,但不會刪除本地檔案。 ### 4\. **提交變更:** 完成後,提交你的變更: ```bash git add .gitignore git commit -m "Ignore db_config.php from git tracking" git push ``` 這樣,`db_config.php` 就會被忽略,而你其他的檔案可以正常推送到 GitLab。 若你上傳檔案時不希望某些目錄(如 "storage" 目錄)被同步到版本控制系統(即不被 Git 追蹤),可以使用 `.gitignore` 檔案來實現。`.gitignore` 是一個特殊的檔案,用來告訴 Git 哪些檔案或目錄應該被忽略,不會被納入版本控制中。 以下是處理方法: ### 步驟: 1. **建立或編輯 `.gitignore` 檔案** 在你的專案根目錄下,檢查是否已經有 `.gitignore` 檔案。如果沒有,可以新建一個: - 在終端機中輸入: ``` touch .gitignore ``` - 或者直接用文字編輯器創建一個名為 `.gitignore` 的檔案。 2. **添加忽略規則** 打開 `.gitignore` 檔案,然後加入你想忽略的目錄或檔案。例如,如果你不希望 "storage" 目錄被同步,添加以下內容: ``` storage/ ``` - 注意:`storage/` 表示忽略名為 "storage" 的目錄及其下所有內容。 - 如果只是想忽略特定檔案,可以寫入檔案名稱,例如 `storage/example.txt`。 3. **檢查已經被 Git 追蹤的檔案** 如果 "storage" 目錄已經被 Git 追蹤(即之前已經被 `git add` 和 `git commit`),單純加入 `.gitignore` 不會生效。你需要先將它從 Git 的追蹤中移除: - 執行以下命令: ``` git rm -r --cached storage ``` 這會移除 "storage" 目錄的追蹤狀態,但不會刪除本地的實際檔案。 4. **提交更改** 修改 `.gitignore` 後,將其提交到 GitLab: ``` git add .gitignore git commit -m "忽略 storage 目錄同步" git push origin <branch-name> ``` 替換 `<branch-name>` 為你目前使用的分支名稱(如 `main` 或 `master`)。 5. **驗證結果** 提交後,"storage" 目錄將不會出現在 GitLab 的版本控制中,即使你在本地仍有該目錄,它也不會被同步到遠端倉庫。 ### 注意事項: - 如果 "storage" 目錄是動態生成的(例如由程式產生),確保它的生成邏輯不會影響專案運行。 - 如果你希望本地保留 "storage" 但不希望它出現在 GitLab,`.gitignore` 是最簡單的解決方案。 - 若專案中其他開發者也需要忽略這個目錄,確保他們拉取最新的 `.gitignore` 檔案。 這樣處理後,"storage" 目錄就不會被同步到 GitLab 的儲存庫中了。如果你有其他具體需求,可以進一步說明,我再幫你調整方案! 補充說明:[專案上傳至GITLab](https://hackmd.io/@labspace/Bk1v9F00A) # <img src="https://labspace.com.tw/assets/upload/product//LabSpace-logo-B-03.png" style="float: left; margin-right: 0.5rem;margin-top:-0.3rem; height: 40px;"> 層次數位空間有限公司 若想要瞭解更多技術資訊或者希望有人可以協助佈建,可洽[層次數位空間有限公司](https://labspace.com.tw) # !! 一個念頭與想法 !! 您有一個很棒的主意或想法嗎?我們聆聽並為您提供快速分析與規劃提案。層次數位讓您的系統平台更有層次。 [![product](https://labspace.com.tw/assets/upload/product//product.png)](https://web.labspace.com.tw)

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