http://9713bbb1.wiz03.com/share/s/2n4XKN1YKkvr2PQq7C18Rgeg2BZisx020QAj2zEMAn3mZxJG

来源:互联网 发布:kali linux ddos 编辑:程序博客网 时间:2024/06/05 22:51
在Coding上建立仓库
    
一、注册Coding并创建项目
①注册:https://coding.net
②配置SSH keys。下载安装git后——单击桌面——Git Bash Here
输入命令
  1. cd ~/. ssh
    如果提示:No such file or directory 说明你是第一次使用git。
生成新的SSH Key:
  1. ssh-keygen -t rsa -C "邮件地址@youremail.com"
其中,邮件地址是你的邮件地址,C是大写。
然后会让你输入要保存的文件名,直接回车就默认id_rsa好了

然后会让你输入两次密码,密码是提交项目时使用的(输入密码的时候不会有显示,直接输入就行了)
如下显示代表生成成功

按着上面的路径找到生成ssh key的目录,如 C:\Users\Administrator\.ssh

用记事本类软件打开id_rsa.pub,将内容复制下来,下一步会用到
③添加SSH Key到Coding
打开Coding页面,打开账户界面 ,点击SSH 公钥,新建一个ssh key将上一步复制的内容粘贴进去,点击添加按钮完成添加

    
    git
下载地址:
        git:https://git-scm.com/download/win

在项目根目录下打开git bash

1.
  1. git init

2.
  1. git add .

3.添加更新说明
  1. git commit -m "First commit"

4.设置提交地址
  1. git remote add origin 提交地址

5.提交
  1. git push origin master


其中可能遇到 Please tell me who you are 这种返回,输入以下命令
  1. git config user.name "用户名"
  1. git config user.email "邮箱"

还可能遇到RSA秘钥不符的,需要生成秘钥添加进Coding,参考建站笔记


出现错误

1.如果之后在AndroidStudio提交代码时,弹出错误:
Can't update: no tracked branch
No tracked branch configured for branch master.
To make your branch track a remote branch call, for example,
git branch --set-upstream master origin/master
 
Push rejected
       Push to origin/master was rejected

原因是没有指定分支,解决方法就是按提示
  1. git branch --set-upstream master origin/master

2.此时可能又出现一个提示:
The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to
Branch master set up to track remote branch master from origin.

我们按着提示重新设置后就可以提交了
  1. git branch --set-upstream-to origin/master

 

3.如果出现了  failed to push some refs to 问题:

error: failed to push some refs to 'git@github.com:hansionit/H-Downloader.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文件不在本地代码目录中
先通过如下命令执行代码合并
  1. git pull --rebase origin master
然后可以看到本地代码库中多了README.md文件,再次push
  1. git push origin master


4.提示:fatal: remote origin already exists
一般在执行第4步时出现,主要原因是已经添加了远程仓库了,如果需要更换,需要先移除远程仓库
  1. git remote rm origin
然后再重新从第4步开始
  1. git remote add origin 提交地址


5.提示:
   warning: LF will be replaced by CRLF in 某文件
   The file will have its original line endings in your working directory.
一般是在执行第2步时出现,但不处理也不会影响提交,主要原因是:
    CRLF 代表CR(Carriage-Return)、LF(Line-Feed)    回车换行
    回车(CR, ASCII 13, \r) 、换行(LF, ASCII 10, \n)
    这两个ACSII字符不会在屏幕有任何输出,但在Windows中广泛使用来标识一行的结束,而在Linux/UNIX系统中只有换行符。
    也就是说在windows中的换行符为 CRLF, 而在linux下的换行符为:LF
    使用git来生成工程后,文件中的换行符为LF, 当执行git add .时,系统提示:LF 将被转换成 CRLF

解决方法:
    删除刚刚生成的.git文件
  1. rm -rf .git
    配置core.autocrlf为false
  1. git config --global core.autocrlf false
   然后重新重第1步开始

阅读全文
0 0
原创粉丝点击