git软件:本地仓库

GitHub网站:远程仓库

代码首先提交到本地仓库(git)[自己使用],再推送到远程仓库(github)[大家一起使用]

 

1.   mac安装git

首先安装git,注册github;然后在github上配置git生成的公钥。

附链接:https://www.cnblogs.com/renhui/p/6882597.html

输入 git --version 测试是否安装成功

2.   idea配置git

附参考链接:https://www.cnblogs.com/hkgov/p/7694101.html

file-->other settings-->default settings-->git,在path处填上本地git安装目录即可(git安装目录获取:终端输入 which git)

                             (mac)IDEA配置git

                              (mac)IDEA配置git

3.   项目提交 

  • 创建本地仓库,在弹框选择要提交的项目,点击ok。(此时项目文件变成红色)
  • 在github上创建一个同名项目。

                            (mac)IDEA配置git

                               (mac)IDEA配置git

  • 项目名称右键,选择git-->add;再项目名称右键,选择git-->commit

选择 git-->add 文件进入暂存区,选择 git-->commit 文件进入版本库。

第一次commit and push时,要输入github上的项目链接,以及github的登录账号和密码。

                                (mac)IDEA配置git

  • 选择要提交的文件,填写提交说明
  • 点击commit后面的倒三角,选择commit and push。

如果没有commit and push选项,就再执行一遍‘项目名称右键,选择git-->add’试试

  • 在弹框,点击“define remote”,输入github上项目链接,点击push即可。

直接点击commit的话,只是提交到了本地仓库,并没有同步到github。

如果每次push都要输入密码,就在终端输入 git config --global credential.helper store ,下次就不用输入密码了。

                                   (mac)IDEA配置git

                                              (mac)IDEA配置git

                                       (mac)IDEA配置git

                                          (mac)IDEA配置git

 

4.   从github上下载项目

  • 新建项目:new-->project from version control-->git

                           (mac)IDEA配置git

  • 在弹框中输入github上的项目链接,下载即可。

                                         (mac)IDEA配置git

  • 下载好项目,就可以进行修改,提交一系列操作。

 

 

 

 

 

 

 

 

 

 

相关文章: