ubuntu git 上传到 bitbucket 已存在工程

bitbucket相比github可以免费的创建私有代码仓库,现在我有一个c语言工程代码,需要上传到bitbucket方便后期维护和保存。
首先登陆bitbucket注册一个账号,后创建一个仓库, 格式如下:
创建私有仓库

上图中,用户名和所有者根据自己的要求设置。

现在回到ubuntu环境下,现在有一个工程文件如下所示:

hello@hello-machine:~/work/other/tmp$ ls -a
.  ..  main.c  Makefile  test.c  test.h

首先执行git init 创建初始版本库

hello@hello-machine:~/work/other/tmp$ git init
初始化空的 Git 版本库于 /home/hello/work/other/tmp/.git/
hello@hello-machine:~/work/other/tmp$ ls -a
.  ..  .git  main.c  Makefile  test.c  test.h

好了,现在就可以吧目前存在的文件添加到仓库了,由于我们拥有多个文件,因此要执行:

git add .

add后面的“.”是将所有文件添加到仓库,之后就可以提交了:

hello@hello-machine:~/work/other/tmp$ git commit -m "this just a test"        
[master (根提交) 7bc4303] this just a test
 4 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 Makefile
 create mode 100644 main.c
 create mode 100644 test.c
 create mode 100644 test.h

接下来就来连接远程仓库,以https的形式连接:

$ git remote add origin  https://bigPillow@bitbucket.org/bigPillow/test.git

其中的后面的地址,可以在创建仓库的时候看到,比如:
这里写图片描述

连接完毕之后,就可以上传代码到远程仓库了:

git push -u origin master

第一次提交需要加上-u参数,这样Git不仅仅把本地的master分支内容推送的远程新的master分支,而且将本地的master分支和远程的master分支关联起来,方面以后推送,假如修改文件后需要再次推送的话,就可以吧-u参数去掉,直接git push origin master就可以了。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值