zoukankan      html  css  js  c++  java
  • git向码云上传代码总结

    1.下载git

    windows下载地址:https://git-for-windows.github.io/

     2.安装git

    一路确定

    3.配置git

     

    如果你要使用ssh上传代码,你需要本地生成ssh

    生成方法:ssh-keygen -t rsa -C   "邮箱地址",一路回车,直到生成ssh key pair

    再执行ssh-add ~/.ssh/id_rsa

    再使用cat ~/.ssh/id_rsa.pub查看key pair,如图:

    打开码云,打开设置,再打开ssh公钥,如图:

     4.测试ssh是否配置成功
    ssh -T git@git.oschina.net ,如果出现welcome to 就代表成功了
    5.代码上传
    git init(初始化git仓库)

    touch README.md (创建帮助文件)

    git add README.md (添加帮助文件)

    git commit -m "注释内容"(添加注释)

    git remote add orgin "你的远程仓库地址"(复制链接后记得加 .git)

    如果使用git push origin master是出现如下问题;

    Username for 'https://github.com',并且需要输入密码的话:

    解决办法:

    git remote set-url origin git+ssh://git@github.com/username/reponame.git

    后面的地址需要这样复制:
    复制下来需要将地址的gitee.com:XXXXX/XXX中的:换成/就可以了

    git add "copy的文件夹"

    git commit -m "添加文件的注释"

    git push -u origin master 上传文件到码云 如果失败如下

    请使用 git push -u origin master -f  

    如果出现fatal: remote origin already exists.

    1、先删除远程 Git 仓库

    $ git remote rm origin

    2、再添加远程 Git 仓库

    回到码云就可以看见上传的文件了。

    如果出现error:src refspec master does not match any

    原因分析

    引起该错误的原因是,目录中没有文件,空目录是不能提交上去的

    解决办法:

    touch README

    git add README

    git commit -m 'first commit'

    git push origin master

    附上问题解决的地点:http://www.open-open.com/lib/view/open1366080269265.html

    -------------以下是工作中get的方法-----------

    1.git status

    查看本地修改的内容以及牵扯到的文件

    2.git pull origin next:master

    是将origin主机的next分支拉下来并且与master合并

    切换分支:

    //切换test分支

    git checkout test

    //创建新的分支

    git checkout -b test

  • 相关阅读:
    HTTP协议详解(真的很经典)
    几点建议,让Redis在你的系统中发挥更大作用
    Redis能干啥?细看11种Web应用场景
    Java中使用Jedis操作Redis
    java的锁机制——synchronized
    web开发中的两把锁之数据库锁:(高并发--乐观锁、悲观锁)
    一分钟教你知道乐观锁和悲观锁的区别
    $^,$@,$?,$<,$(@D),$(@F) of makefile
    linux shared lib 使用与编译
    makefile learning
  • 原文地址:https://www.cnblogs.com/huhu1203/p/7565636.html
Copyright © 2011-2022 走看看