初始化GIT仓库
对于Eclipse已有的项目,如果想要初始化为git仓库,可以选中项目右键,选择
Team-->Share Project
然后在新弹出的界面中勾选use or create repository
,选中项目,点击create repository
,点击finish完成。![](https://img2018.cnblogs.com/i-beta/1102240/202002/1102240-20200225085452404-873537864.png)
提交项目到远程仓库
在github中新建一个空的仓库,仓库名与项目名保持一致,然后在Eclipse中选中项目右键,选择Team-->commit
在新弹出的界面中,填写提交信息,下面的文件全部勾选或者根据需要选择,点击commit and push
按钮进行提交。
![](http://upload-images.jianshu.io/upload_images/14795543-3c29f31811672b2a.png?imageMogr2/auto-orient/strip|imageView2/2/w/620/format/webp)
将github中项目的https地址复制到URI中,然后选择Protocol为https,在下面输入远程服务器的帐号和密码,可以勾选store in secure store
进行帐号保存,点击Next
![](http://upload-images.jianshu.io/upload_images/14795543-a49a4846a578e542.png?imageMogr2/auto-orient/strip|imageView2/2/w/620/format/webp)
下一步继续点击Next,然后点击finish完成。
![](http://upload-images.jianshu.io/upload_images/14795543-69bb22fab979a4b0.png?imageMogr2/auto-orient/strip|imageView2/2/w/620/format/webp)
push完成后刷新远程仓库查看项目代码是否成功上传。
![](http://upload-images.jianshu.io/upload_images/14795543-43cab296af1cdac2.png?imageMogr2/auto-orient/strip|imageView2/2/w/900/format/webp)