将自己代码提交到github上的方法(可在idea的终端下操作)

将代码提交到github上托管的方式有一下几种:

(1)github上未建仓库

//在git上执行命令
echo "# abbc" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/XXX/xxx.git
git push -u origin master

在idea终端中执行代码后,成功上传到github仓库中。

huadeMacBook-Pro:springbootproject huayu$ echo "#springboot+maven+mybaits+druid">>README.md
huadeMacBook-Pro:springbootproject huayu$ git init
Initialized empty Git repository in /Users/huayu/Documents/workspace/springbootproject/.git/
huadeMacBook-Pro:springbootproject huayu$ git add README.md 
huadeMacBook-Pro:springbootproject huayu$ git commit -m "first commit"
[master (root-commit) e4d1101] first commit
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
huadeMacBook-Pro:springbootproject huayu$ git remote add origin https://github.com/Myuhua/springbootdemo.git
huadeMacBook-Pro:springbootproject huayu$ git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 235 bytes | 235.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)

(2)github上已经建好了仓库

//在终端执行git命令
git remote add origin https://github.com/XXX/xxx.git
git push -u origin master

 在终端执行代码后,成功上传github仓库中。

192:springbootproject huayu$ git remote add origin https://github.com/Myuhua/springbootdemo.git
192:springbootproject huayu$ ls
pom.xml                 springbootproject.iml   src                     target
192:springbootproject huayu$ git push -u origin master
Counting objects: 100, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (91/91), done.
Writing objects: 100% (100/100), 16.58 KiB | 1.27 MiB/s, done.
Total 100 (delta 56), reused 0 (delta 0)
remote: Resolving deltas: 100% (56/56), done.
remote: 
remote: Create a pull request for 'master' on GitHub by visiting:
remote:      https://github.com/Myuhua/springbootdemo/pull/new/master
remote: 
To https://github.com/Myuhua/springbootdemo.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

这是成功上传的到github的仓库截图,以前csdn传图片调整大小什么的都挺好用的,csdn改这版后上传图片调整大小费劲的要命!!我问了csdn的工作人员,图片大小调整功能暂时下线了, 大家先将就看吧,等他们修改上线后我再调整。

(3)在github仓库从另一个存储库导入代码,创建一个新的空仓库后,点击新创建的仓库,下面页面中有个import code按钮,进入后页面是这个样子的,然后你输入你的旧存储库的url将代码导入进来就可以了。(前提是github得支持的旧仓库才可以)

若有问题欢迎大家与我互动交流,如果文章帮到了你,请点小手指。另外,我的博客文章会不定期更新,喜欢的朋友可以加一下关注。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小猿架构

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值