ubuntu git 上传到 bitbucket 已存在工程
2016-06-09 11:40
323 查看
bitbucket相比github可以免费的创建私有代码仓库,现在我有一个c语言工程代码,需要上传到bitbucket方便后期维护和保存。
首先登陆bitbucket注册一个账号,后创建一个仓库, 格式如下:
上图中,用户名和所有者根据自己的要求设置。
现在回到ubuntu环境下,现在有一个工程文件如下所示:
首先执行git init 创建初始版本库
好了,现在就可以吧目前存在的文件添加到仓库了,由于我们拥有多个文件,因此要执行:
add后面的“.”是将所有文件添加到仓库,之后就可以提交了:
接下来就来连接远程仓库,以https的形式连接:
首先登陆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[/code]
其中的后面的地址,可以在创建仓库的时候看到,比如:
连接完毕之后,就可以上传代码到远程仓库了:git push -u origin master
第一次提交需要加上-u参数,这样Git不仅仅把本地的master分支内容推送的远程新的master分支,而且将本地的master分支和远程的master分支关联起来,方面以后推送,假如修改文件后需要再次推送的话,就可以吧-u参数去掉,直接git push origin master就可以了。
相关文章推荐
- RPC failed; result=22, HTTP code = 411
- git更新已經刪除的文件
- 提取Git每次提交后Commit的文件
- GIT迁移服务器
- 分布式版本管理git入门指南使用资料汇总及文章推荐
- git终极指南:在实际开发中的应用
- js 提交和设置表单的值
- PHP+JS实现大规模数据提交的方法
- AJAX提交表单数据实例分析
- jQuery同步提交示例代码
- jQuery实现数秒后自动提交form的方法
- jQuery实现提交按钮点击后变成正在处理字样并禁止点击的方法
- jQuery改变form表单的action,并进行提交的实现代码
- 使用jquery提交form表单并自定义action的实现代码
- JavaScript阻止回车提交表单的方法
- js与jquery回车提交的方法
- 纯javascript的ajax实现php异步提交表单的简单实例
- 使用jquery提交form表单并自定义action的方法
- jQuery提交多个表单的小例子
- button没写type=button会导致点击时提交