gitee使用教程,创建项目仓库并上传代码
发布日期:2021-06-30 19:35:43
浏览次数:3
分类:技术文章
本文共 4134 字,大约阅读时间需要 13 分钟。
文章目录
一、关于gitee
gitee
(中文名:码云 ,原名 Git@OSC
)是开源中国推出的基于git
的代码托管服务。
GitHub
速度比较慢,如果想托管自己的代码到云端,gitee
是个不错的选择,华为的鸿蒙2.0
源码也是放在gitee
上的。 二、安装git
要使用gitee
,需要先安装git
工具。
git
工具下载: 安装完成后,在命令行输入git --version
可以查看到git
的版本。 右键菜单也会出现相应的菜单。
三、登录gitee
我们先在 gitee
上注册账号并登录。
gitee
官网: 四、生成SSH公钥
由于我们的本地 git
仓库和 gitee
仓库之间的传输是通过SSH
加密的,所以我们需要配置SSH
公钥。
注:安装了
git
工具,就可以使用ssh
命令
打开cmd
命令行,输入命令
ssh-keygen -t rsa -C "xxxxx@xxxxx.com"
按照提示完成三次回车,即可生成注意:这里的
xxxxx@xxxxx.com
只是生成的 sshkey 的名称,并不约束或要求具体命名为某个邮箱。
ssh key
。 可以看到,我们生成的公钥文件id_rsa.pub
路径:C:\User\Adminstrator/.ssh/id_rsa.pub
进入该目录用文本编辑器打开 即可看到SSH
公钥,下文中将会用到这个SSH
公钥。 五、配置SSH公钥
在gitee
网站点击设置
SSH
公钥 输入公钥标题,拷贝刚刚的SSH
公钥到框中,点击确定 配置成功 六、创建一个项目
点击右上角的 +
号,新建仓库
七、克隆仓库到本地
点击克隆/下载
,然后点击SSH
,复制git
链接
Git Bash Here
。 输入git clone 刚刚的git链接
,如下 git clone git@gitee.com:linxinfa/mytest.git成功后,本地目录即可看到克隆下来的
README
文件。 八、关联本地工程到远程仓库
有时候,我们可能是先在本地有了工程文件,然后再在gitee
上创建仓库的。
git remote add
把它和 gitee
的远程库关联,如下 git remote add origin git@gitee.com:linxinfa/mytest.git
如果在使用命令 git remote add
时报错:
git remote add origin git@gitee.com:linxinfa/mytest.gitfatal: remote origin already exists.
说明本地库已经关联了一个名叫 origin
的远程库,此时,可以先用git remote -v
查看远程库信息:
git remote -vorigin git@gitee.com:linxinfa/mytest.git (fetch)origin git@gitee.com:linxinfa/mytest.git (push)
我们可以删除已有的远程库
git remote rm origin
再关联远程库
git remote add origin git@gitee.com:linxinfa/mytest.git
九、添加文件
在本地添加文件,如下,添加一个AddFileTest.txt
文件。
十、执行git命令,提交文件
打开git
,执行git
的add
、commit
、push
命令,即可将本地文件上传到远程仓库。
git
命令见文章最后面。 刷新gitee
页面,即可看到本地文件已经上传到```gitee``上了 十一、删除仓库
点击管理
十二、常用的git命令
常用的git
命令
git init #把当前目录变成git可以管理的仓库git add readme.txt #添加一个文件,也可以添加文件夹git add -A #添加全部文件git rm test.txt #删除一个文件,也可以删除文件夹git commit -a -m "some commit" #提交修改git status #查看是否还有未提交git log #查看最近日志git reset --hard HEAD^ #版本回退一个版本git reset --hard HEAD^^ #版本回退两个版本git reset --hard HEAD~100 #版本回退多个版本git remote add origin +地址 #远程仓库的提交(第一次链接)git push -u origin master #仓库关联git push #远程仓库的提交(第二次及之后)更多的
git
命令,可以输入git --help
查看,或者访问git
命令手册: git --helpusage: git [--version] [--help] [-C] [-c = ] [--exec-path[= ]] [--html-path] [--man-path] [--info-path] [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare] [--git-dir= ] [--work-tree= ] [--namespace= ] [ ]These are common Git commands used in various situations:start a working area (see also: git help tutorial) clone Clone a repository into a new directory init Create an empty Git repository or reinitialize an existing onework on the current change (see also: git help everyday) add Add file contents to the index mv Move or rename a file, a directory, or a symlink restore Restore working tree files rm Remove files from the working tree and from the index sparse-checkout Initialize and modify the sparse-checkoutexamine the history and state (see also: git help revisions) bisect Use binary search to find the commit that introduced a bug diff Show changes between commits, commit and working tree, etc grep Print lines matching a pattern log Show commit logs show Show various types of objects status Show the working tree statusgrow, mark and tweak your common history branch List, create, or delete branches commit Record changes to the repository merge Join two or more development histories together rebase Reapply commits on top of another base tip reset Reset current HEAD to the specified state switch Switch branches tag Create, list, delete or verify a tag object signed with GPGcollaborate (see also: git help workflows) fetch Download objects and refs from another repository pull Fetch from and integrate with another repository or a local branch push Update remote refs along with associated objects'git help -a' and 'git help -g' list available subcommands and someconcept guides. See 'git help ' or 'git help 'to read about a specific subcommand or concept.See 'git help git' for an overview of the system.
转载地址:https://linxinfa.blog.csdn.net/article/details/108709835 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
网站不错 人气很旺了 加油
[***.192.178.218]2024年05月04日 14时42分37秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
调试 LenaCV 3D Camera (Linux)
2019-04-30
OpenCV杂记 - Mat in C++
2019-04-30
lnmp部署
2019-04-30
nginx平滑升级
2019-04-30
location区段
2019-04-30
nginx访问控制、基于用户认证、https配置
2019-04-30
用zabbix监控nginx
2019-04-30
rewrite和if语句
2019-04-30
nginx实现负载均衡和动静分离
2019-04-30
SaltStack
2019-04-30
Packer 如何将 JSON 的配置升级为 HCL2
2019-04-30
Ubuntu 安装 NTP 服务
2019-04-30
NeoFetch - Linux 使用命令行查看系统信息
2019-04-30
Jenkins 控制台输出中的奇怪字符
2019-04-30
Linux添加系统调用
2019-04-30
ubuntu 18 CTF 环境搭建
2019-04-30
linux内存的寻址方式
2019-04-30
[off by null + tcache dup]lctf_easy_heap
2019-04-30