演示怎麼用Mac SourceTree提交Android程式碼到GitHub
SourceTree:因為Git預設只能使用命令列模式進行一系列的操作,而SourceTree解決了這個問題並以圖形化管理Git。
這篇文章主要講SourceTree怎麼管理,提交程式碼至GitHub。因為是使用SourceTree連線GitHub所以整篇文章只需要一處使用到命令列,需要顯示隱藏檔案,在命令列輸入。
defaults write com.apple.Finder AppleShowAllFiles Yes && killall Finder //顯示隱藏檔案
defaults write com.apple.Finder AppleShowAllFiles No && killall Finder //不顯示隱藏檔案
在開始前要設定顯示隱藏檔案,介紹絕對詳細的一篇文章。
一、在GitHub建立倉庫
圖1
圖2
圖3
這樣就是建立好GitHub倉庫了。
二、SourceTree連線GitHub
圖4
英語不好?想在網上找漢化版SourceTree?根本不用找,SourceTree可以選擇不同操作語言,很是貼心,別忘了設定好重啟SourceTree才會生效。
下面仍然使用US版演示。
圖5
圖6
圖7
到這一步算是SourceTree和你的GitHub賬號關聯成功
三、把原生程式碼提交到GitHub
圖8
先在本地建立一個空資料夾,雖然SourceTree會預設地址建立一個空資料夾,但我更喜歡指定某個路徑下自己建立。
圖9

圖10




接著把你要上傳的專案複製到.git同目錄下
圖14

點開SourceTree,SourceTree已經檢測到專案存在,但此時專案並未上傳到GitHub。
圖15







完成這一步去重新整理的GitHub!
圖22

提交成功!
四、通過SourceTree程式碼更新至GitHub
圖23

注意!此時你用Android Studio開啟的專案就是你建立空檔案下.git同目錄的那個專案,這樣SourceTree才會監測程式碼是否改動,下面舉個例子。
圖24

我的GitHub上MainActivity.class
圖25

在本地專案改變了MainActivity。
圖26






SourceTree提交更新程式碼哪怕是一個類也慢的一比。

去GitHub重新整理MainActivity可以看到剛才從SourceTree改動並更新過的程式碼!
到此為止演示SourceTree上傳程式碼至GitHub完成。
五、從GitHub刪除專案
沒有用的專案怎麼從GitHub刪除呢?
圖33

到你想要刪除的專案中,點Settings
圖34

這是刪除GitHub上的專案
圖35

這是刪除SourceTree上的專案
SourceTree繫結GitHub賬戶——通過SourceTree上傳專案到GitHub——通過SourceTree更新程式碼到GitHub——GitHub刪除專案
整個演示流程結束。
命令列也可以提交程式碼,但我更喜歡用圖形工具SourceTree來提交,這樣整個專案結構看起來更直接而且有筷子為啥還要用手吃飯呢?