# Giiiiiiiit ### Reference - [svn/git 的較](https://stevenjhu.com/2019/11/11/%E7%89%88%E6%9C%AC%E6%8E%A7%E7%AE%A1vcs-%E5%9F%BA%E7%A4%8E%E6%A6%82%E5%BF%B5%EF%BC%8Csvn%E3%80%81git%E6%AF%94%E8%BC%83/) ### Git 安裝 #### Windows 環境 - [Git 下載](https://git-scm.com/downloads) Step 1: 下載ta - Downloads -> Windows -> Click here to download Setp 2: 安裝ta - 下載後會看到這個,直接執行,什麼都不用調整,一路按到最後一步,結束。 ![](https://i.imgur.com/tXRj1tQ.png) #### Mac - 待補 #### Linux - ubuntu ``` sudo apt-get install git-all ``` ### Git Cloud 平台 #### BitBucket - [BitBucket 連結](https://www.atlassian.com/enterprise/data-center/bitbucket) - 進入連結後,用google帳號註冊 - 註冊完後會看到以下畫面,點選切換到BitBucket。 ![](https://i.imgur.com/ONHyElD.png) - Step1: Create Work Space ![](https://i.imgur.com/DVfeuaD.png) - Step2: Create Repository/Project ![](https://i.imgur.com/zjyzUwN.png) Advanced settings 可以做一些專案客製化的設定,可以選擇你要使用的程式語言,或是用來幹嘛的,他會根據你的設定,自動創建.gitignore檔案,我這裡以javascript為例。 .gitignore是用來讓git判斷什麼東西需要被推上remote,什麼東西要留在本地不需要推上去的檔案。 - clone 你的專案 創建好的專案應該會長這樣 ![](https://i.imgur.com/NQoMQaO.png) 右上角一個Clone的按鈕,給他點下去 ![](https://i.imgur.com/zexyL3C.png) 如果SourceTree已經設定好,可以點右下角Clone in Sourcetree - #### GitHub - 待補 #### GitLab - 待補 ### Source Tree - [Source Tree 介紹與安裝教學](https://ithelp.ithome.com.tw/articles/10206852) - [SourceTree](https://www.sourcetreeapp.com/) ## 來用SourceTree進行版本控制 - 我們先來觀察剛才拉下來的專案資料夾會長成下面的東西,其中的.git資料夾,就是版本控制的核心,通常放著也不太會沒事打開他。 ![](https://i.imgur.com/RHkYzck.png) [SurceTree操作Git 基礎教學](https://medium.com/samumu-clan/%E7%94%A8-sourcetree-%E5%AF%A6%E7%8F%BE%E5%9F%BA%E7%A4%8E%E7%89%88%E6%9C%AC%E7%AE%A1%E6%8E%A7-b007254e95c5) ## 練習 1. 在master分支上,創建一個檔案,檔名為index.js 2. commit 這個變動,commit 訊息叫做 "feat: add file index.js" 3. push 到remote 4. 開一個分支(branch),分支名稱叫做HelloGit 5. 切換到HellowWorld分支,在index.js 檔案裡,寫下一段可以在終端機印出"HelloGit" 的js 程式碼。 6. commit 這個改動,並將這個分支push 到remote。 7. 回到master分支,將HelloGit 分支合併進來(merge) 8. 將master push 到remote