1.首先在https://github.com/申請一個賬戶,記下用戶名和密碼
2.然後到Android Studio打開Setting,找到Github
3.輸入用戶名和密碼後點擊Test,測試是否能連接上,這裏我已經連接成功了
4.在電腦上安裝git,去官網上下載即可
5.安裝git後,進入Android Studio,打開Git配置
配置完git.exe路徑
6.配置完git.exe路徑後點擊Test,如圖(我的Git version 是 2.9.3.0)
如果提示成功就可以關閉Setting對話框了,然後我們學習怎樣把項目提交到github上
7.正好我這裏寫了一個項目,是測試百度地圖的截圖功能,我們把它提交到github上,點擊VCS->Enable Version Control Intergration開啓版本控制
8.點擊後彈出如下對話框,選擇Git
點擊OK,會在底部提示創建成功一個倉庫。查看倉位文件夾可以到對應的項目文件的詳細位置查看,不過這個文件夾是隱藏文件,同時可以發現這是的項目文件變成紅色的了,如圖:
9.然後開始上傳到github,點擊Share Project on Github
10.填寫信息後點擊,Share
11.點擊Share後選擇初始導入文件,默認已經全選
然後點擊OK,會有個提示
不上傳vcs.xml這個文件,點擊No
12.然後右側出現個提示
Successfully created project ‘CaptureTest’ on GitHub, but initial commit failed: * Please tell me who you are. Run git config –global user.email “[email protected]” git config –global user.name “Your Name” to set your account’s default identity. Omit –global to set the identity only in this repository. fatal: empty ident name (for (null)>) not allowed during executing git -c core.quotepath=false commit -m “Initial commit” –
意思是:在github上創建項目已經成功了,但是初始化提交失敗了,原因是首次沒有設置身份:運行
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
設置郵箱和用戶名。然後我們設置一下
到Git安裝目錄下找到git-bash.exe,雙擊打開,然後運行上述兩個命令
13.右鍵項目Git-Commit Directory
14.默認全選後輸入Commit message
在Commit中選擇Commit and Push,然後等待Pushing
15.成功後刷新Github就可以看到了