gitee教程

二、安装git

要使用gitee,需要先安装git工具。
git工具下载:Git - Downloadshttps://git-scm.com/downloads

下载好后,检查是否真的下载了: 

三、登录gitee

我们先在 gitee上注册账号并登录。
gitee官网:Gitee - 企业级 DevOps 研发效能平台面向企业提供一站式研发管理解决方案,包括代码管理、项目管理、文档协作、测试管理、CICD、效能度量等多个模块,支持SaaS、私有化等多种部署方式,帮助企业有序规划和管理研发过程,提升研发效率和质量。https://gitee.com/

四、生成SSH公钥

由于我们的本地 git仓库和 gitee仓库之间的传输是通过SSH加密的,所以我们需要配置SSH公钥。

1)打开git bash,在哪里鼠标右键都行,因为目前还在配置。

 2)输入代码来实现git账户和本地的关联。

ssh-keygen -t rsa -C "你的邮箱"

一直回车,一共三次,虽然出现了冒号,但是不用填。 

3)结束后输入来查看自己的密钥:

cat ~/.ssh/id_rsa.pub

4) 将下面的密钥全部复制到网站上去:

官网右上角——个人设置——ssh公钥——标题是随意取——公钥文本输入框复制上面的密钥——确定。

配置成功 

 5)测试是否连接到远程自己的账号。

 ssh -T git@gitee.com

6)复制ssh的地址

打开官网,创建仓库

创建成功跳转过后,点击克隆下载,然后复制ssh的地址来进行上传下载(后面会用到地址)

六、创建一个项目

点击右上角的 +号,新建仓库

 如下,填写仓库信息,最后点击创建即可。

4、上传文件到gitee

1)新建文件夹

2)进入刚刚新建的文件夹,点击鼠标右键,选择"Git Bash Here",如下图:

3)进行基础配置,也叫全局设置,作为 git 的基础配置,作用是告诉 git 你是谁,你输入的信息将出现在你创建的提交中,使用下面两条命令:

  git config --global user.name "你的名字或昵称"
  git config --global user.email "你的邮箱"

 4)输入初始化命令 git init  回车——这步是将本地文件初始化为本地仓库。

文件夹出现了隐藏文件夹。

 git init 

5)输入要链接到码云的地址,(前面我们复制的地址)  回车。

git remote add origin 地址

6)在这个新建文件夹里随便放个文件。

插入一下,输入可以查看这个文件夹的文件装填

命令用于查看在你上次提交之后是否有对文件进行再次修改

git status 

7)输入命令:

git add .

8)添加注释,来说明自己为什么要上传,方便以后自己查阅 例如:

 git commit -m "第一次上传" 

9)提交到码云上面

第一次提交:

git push -u origin master

后面几次提交:

git push origin master

注意:如果最后一步报错,可以使用 git push -f origin master,来强制覆盖。

git push origin master //(正常提交)和
git push origin master -f //(强制提交,强制提交可能会把之前的commit注释信息,不会改变修改的代码,慎用),都是提交到master分支

克隆仓库到本地

点击克隆/下载,然后点击SSH,复制git链接

 鼠标右键——打开git bash——复制ssh链接——输入命令 git clone 

git clone "克隆的SSL"

删除仓库

常用的git命令

常用的git命令​​​​​​​

git init 					#把当前目录变成git可以管理的仓库
git clone 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 fetch 					#从远程获取代码库
git tag xxx 				#打tag
git tag 					#显示所有tag
git push --tag 				#提交tag
git branch -a 				#显示所有分支
git checkout 分支名 		#切换分支
git merge git分支 			#合并分支

更多的git命令,可以输入git --help查看,或者访问git命令手册:Git - Reference

git --help
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

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 one

work 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-checkout

examine 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 status

grow, 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 GPG

collaborate (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 some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值