GITEE

简易的命令行入门教程:

Git 全局设置:

git config --global user.name "#名字#"        	#必用命令
git config --global user.email "#邮箱#"			#必用命令

一、用https上传文件

mkdir test
cd test
git init			#必用命令
touch README.md
git add README.md			#必用命令
git commit -m "first commit"			#必用命令
git remote add origin https://gitee.com/#名字#/test.git			#必用命令
git push -u origin master			#必用命令

二、用ssh上传文件

在使用SSH协议访问仓库仓库之前,需要先配置好账户/仓库的SSH公钥。

yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~$ ssh-keygen -t rsa -C "#邮箱#"

接着直接按三次回车,即可生成 ssh key。通过查看 ~/.ssh/id_rsa.pub 文件内容,获取到public key

yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~$ cat ~/.ssh/id_rsa.pub 

在这里插入图片描述复制生成后的 ssh key后,登录码云–>‘设置’–>安全设置里的‘SSH公钥’
标题填写好后,粘贴ssh key,确定。
添加后,在终端(Terminal)中输入ssh -T git@gitee.com

yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~$ ssh -T git@gitee.com

首次使用需要确认并添加主机到本机SSH可信列表。若返回 Hi XXX! You’ve successfully authenticated, but Gitee.com does not provide shell access. 内容,则证明添加成功。
结束

<`````````````````````````分 隔 符1````````````````````````>

<`````````````````报 错 模 板````````````````>
报错记录:

×××××

报错代码

解决方式 :×××××
解决命令 :

解决代码

<`````````````````````````分 隔 符1````````````````````````>
报错记录:

error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large

yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~/gitee/cloud_storage$ git add java
yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~/gitee/cloud_storage$ git push -u origin master 
Username for 'https://gitee.com': wenjie1388
Password for 'https://wenjie1388@gitee.com': 
对象计数中: 7, 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (7/7), 完成.
写入对象中: 100% (7/7), 541.06 MiB | 7.04 MiB/s, 完成.
Total 7 (delta 0), reused 0 (delta 0)
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date

解决方式:使用ssh上传将不受限制
解决命令:

yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~/gitee/cloud_storage/front-end$ git pull
warning: 没有共同的提交
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 15 (delta 2), reused 0 (delta 0)
展开对象中: 100% (15/15), 完成.
来自 https://gitee.com/wenjie1388/cloudstorage
 * [新分支]          master     -> origin/master
当前分支没有跟踪信息。
请指定您要合并哪一个分支。
详见 git-pull(1)。

    git pull <远程> <分支>

如果您想要为此分支创建跟踪信息,您可以执行:

    git branch --set-upstream-to=origin/<分支> master


报错记录:

更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支

yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~/gitee/cloud_storage/front-end$ git push -u origin master 
Username for 'https://gitee.com': wenjie1388
Password for 'https://wenjie1388@gitee.com': 
To https://gitee.com/wenjie1388/cloudstorage.git
 ! [rejected]        master -> master (non-fast-forward)
error: 推送一些引用到 'https://gitee.com/wenjie1388/cloudstorage.git' 失败
提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。
提示:再次推送前,先与远程变更合并(如 'git pull ...')。详见
提示:'git push --help' 中的 'Note about fast-forwards' 小节。

<`````````````````````````分 隔 符2````````````````````````>
报错记录:

fatal: 远程 origin 已经存在。

yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~/gitee/cloud_storage/java$ git remote add origin https://gitee.com/×××××/cloudstorage/tree/java.git
fatal: 远程 origin 已经存在。

解决方式:移除远程origin。

拓展:origin是什么?
“origin” 是当你运行 git clone或git push 时默认的远程仓库名字。默认的远程分支名字将会是 booyah或者master,我这里常使用的master(根)分支。

解决命令:

yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~/gitee/cloud_storage/java$ git remote rm origin

<`````````````````````````分 隔 符3````````````````````````>
报错记录:

您尚未结束您的合并,请在合并前先提交您的修改。

yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~/gitee/cloud_storage/front-end$ git pull
error: 您尚未结束您的合并(存在 MERGE_HEAD)。
提示:请在合并前先提交您的修改。
fatal: 因为存在未完成的合并而退出。

解决方式:提交本地修改
解决命令:

yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~/gitee/cloud_storage/front-end$ git merge --abort
yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~/gitee/cloud_storage/front-end$ git reset --merge
yiwang@yiwang-Lenovo-XiaoXin-RUI7000:~/gitee/cloud_storage/front-end$ git pull
当前分支没有跟踪信息。
请指定您要合并哪一个分支。
详见 git-pull(1)。

    git pull <远程> <分支>

如果您想要为此分支创建跟踪信息,您可以执行:

    git branch --set-upstream-to=origin/<分支> master

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值