在idea中利用git上传项目到GitHub

369 阅读1分钟

下载git

下载git


在github上创建远程仓库

在github的右上角,点击加号下方的 New repository
Repository name 输入框中输入远程仓库名
Description (optional)输入框中添加对项目的描述
然后点击下方的绿色按钮,创建远程仓库完成。

在github上创建远程仓库后,会自动生成URL,在idea上传到github上时会用到

操作命令

  • 在idea中打开Terminal

  • git初始化本地仓库

  • 在命令行中输入 git init
    将本地代码提交到本地仓库中

  • 在命令行中输入
    git add *
    git commit -m '提交内容的描述'

注意,单引号内输入对本次提交的内容的描述,不写会出错将本地仓库与远程仓库进行绑定,并且push

git remote add origin 你的远程仓库的URL

//例如

git remote add origin https://github.com/xxxxxxxxxxxx

  • 将代码提交到github上

git push origin master