温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

git 创建本地仓库与 gitcafe 关联

发布时间:2020-07-03 19:49:56 来源:网络 阅读:601 作者:菜鸟的征程 栏目:开发技术
git init                               # 创建本地仓库
# 设置远程仓库地址,这里可以设置ssh 或 https 的形式,此处设置为https 格式,
# ssh 格式为 : git  remote add origin git@coding.net:sql031625/test.git
git remote add origin https://git.coding.net/sql031625/test.git         

touch a.py        # 创建文件,使仓库有新的变更
git add .        # 添加所有变更
git  commit  -m  'first'               # 注释
git push -u oringin  master            # 推送代码,第一次使用 -u ,以后便可以不使用 -u 参数 
                                # 可以设置 git config --global push.default matching命令,使得push命令默认push到github的同名仓库中

若最后一步出错,

ralap@Ubuntu:~/data/coder/webtest$ git push -u origin master
Username for 'https://git.coding.net': sql031625
Password for 'https://sql031625@git.coding.net': 
To https://git.coding.net/sql031625/test.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://git.coding.net/sql031625/test.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

原因分析:在github上重新创建仓库,建立README.md,导致该文件不在本地代码中,执行以下命令,将git 仓库中的文件与本地合并,然后再上传即可

git pull --rebase origin master
git push -u oringin  master


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI