本章假定你已經安裝了 git 客戶端,本文僅僅使用與 Mac 環境下,未在 Window下實驗,但 IDEA 在 Window 和 Mac 下軟件的使用方法是一致的。git
1 配置帳號
IDEA 須要配置 git 和 github 兩個配置。github
1.1 配置 git
- 點擊 IntelliJ IDEA-EAP > Preferences > Version Control > Git 注意有說菜單是 Setting > Version Control > Git 你們自行尋找對應的配置。
- Path to Git executable: 選項中 填寫 git 所在路徑 在 mac 中找不到路徑 在終端輸入
whereis git
會顯示 git 所在目錄,我這裏是 /usr/bin/git
點擊【apply】應用此設置 
1.2 配置 github
- 點擊 IntelliJ IDEA-EAP > Preferences > Version Control > github 注意有說菜單是 Setting > Version Control > Git 你們自行尋找對應的配置。
- 在右側輸入對應參數
- host 輸入 github.com
- auth type 選擇 password
- login 輸入 github 用戶名
- password 輸入 github 密碼
- 設置完成後可點擊 test 按鈕進行測試
- 點擊【apply】應用此設置

2 初次提交代碼到 Github
第一次提交到 Github 有個在 Github 創建倉庫的過程,app
- 添加 IDEA 頂部菜單 VCS > Import into Verstion Control > Share Project on Github
- 進入彈窗 填寫
- New respository name: 在 github 上的名字,這個名字必須是 github 上尚未的
- private 若是是私有的不公開的,就打鉤
- Remote name :這個默認 origin 不用動
- Description 初次的描述就是 github 上的項目描述
- 填寫好後點擊 share 按鈕

- 在彈出的提交窗口提交你須要提交的文件,這裏主要要去掉 .ideal .mvn .mvnw 文件 不用提交,能夠在 Commit Message 裏面提交本次提交的描述
- 在您的 github 主頁查看提交的倉庫,能夠看到新建的倉庫

3 修改代碼並提交
- 右鍵須要提交的文件夾或者包名或者文件名
- 選擇 git > add 若是您的項目文件(灰色狀態)尚未加入到 git 配置庫,默認都是 IDEA 自動加入的
- 選擇 git > commit File 先向本地 git 倉庫提交 注意必須先提交到本地 git 倉庫,才能提交到遠程 github 倉庫
- 選擇 git > respository > push 向遠程 github 倉庫提交本地倉庫內容
總結ide
- github 依賴於 git,必須先安裝 git 環境
- 提交到 github 倉庫順序是,從 項目文件 -> add 到 項目 git 倉庫文件中 ->提交到本地git倉庫 -> 從 git 倉庫提交大 github 倉庫