安裝git
此處省略。。。
生成ssh key
打開運行Git Bash
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
默認生成在 C:\Users\Administrator\.ssh目錄
在遠程倉庫管理界面增加ssh key設置 key的內容為之前在本機生成ssh key目錄下的id_rsa.pub文件內容
IDEA默認已經集成了git插件,需要配置
在IDEA中設置Git,在File-->Setting->Version Control-->Git-->Path to Git executable
選擇你的git安裝后的git.exe文件,然后點擊Test,測試是否設置成功
File-->Setting->Version Control->Git中,將SSH executable設置為Native
新項目上傳到遠程倉庫:
1.在idea新建一個項目
2.創建本地倉庫,VCS-->Import into Version Control-->Create Git Repository.
在彈框中選中項目所在的位置,點擊OK,此時項目文件全部變成紅色
3.上傳項目到本地倉庫,項目右鍵選擇Git-->add,此時項目文件變成綠色,此時文件只是處於暫存區,並沒有真正進入到版本庫中
項目右鍵Git--> Commit Directory,在彈窗中輸入Commit Message,點擊commit,此時項目文件從暫存區真正進入版本庫中,項目文件變成白色
4.上傳項目到遠程倉庫,項目右鍵選擇Git-->push 填寫遠程倉庫地址,有可能會出現Push rejected: Push to origin/master was rejected,這時需要先Pull再Push
從遠程倉庫項目直接檢出:
VCS->checkout from version control->git