手把手教你如何上传代码到gitee服务器

2023-05-28 0 157

以后撰写了两个适宜初学者的小工程项目, 为方便快捷我们自学和浏览标识符, 下定决心把标识符上载至gitee伺服器。

不得已说,git是两个十分称心的标识符版管理软件,

责任编辑亲自动手教我们怎样将他们撰写的标识符上载至Gitee。

1. 注册登记帐号

关上页面

https://gitee.com/
手把手教你如何上传代码到gitee服务器

点选注册登记, 输出两个他们讨厌的搜索引擎,yikoulinux 输出电话号码,校正方可

手把手教你如何上传代码到gitee服务器

点选注册登记并存取 方可。

手把手教你如何上传代码到gitee服务器

2.存取QQ

点选头像->设置

手把手教你如何上传代码到gitee服务器
手把手教你如何上传代码到gitee服务器

2. 存取邮箱

后续版管理操作需要存取邮箱才能继续操作。

点选头像->设置

手把手教你如何上传代码到gitee服务器

点选 左边邮箱管理->新增 然后输出刚才设置的gitee登录密码

手把手教你如何上传代码到gitee服务器

正确会进入下面页面, 输出他们的邮箱(一口君用的QQ邮箱)

手把手教你如何上传代码到gitee服务器

点选确定

手把手教你如何上传代码到gitee服务器

然后登录他们邮箱,点选对应的链接方可。

手把手教你如何上传代码到gitee服务器

3. 新建仓库

点选头像左侧的+ -> 新建仓库

手把手教你如何上传代码到gitee服务器

输出名称以及开源许可证等。

手把手教你如何上传代码到gitee服务器

点选创建方可。

4. clone克隆仓库到本地

复制仓库链接:

手把手教你如何上传代码到gitee服务器

进入ubuntu 如果没有安装git,可以执行以下命令安装git

sudo apt-get install git

配置git全局环境

git config —global user.name “yikoulinux” git config —global user.email “7335817@qq.com”

修改commit默认关上的文本编辑工具

git config —global core.editor “vim”

开始克隆:

root@ubuntu:/home/peng/work# git clone https://gitee.com/yikoulinux/encryption.git Cloning into encryption remote: Enumerating objects: 4, done. remote: Counting objects: 100% (4/4), done. remote: Compressing objects: 100% (4/4), done. remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (4/4), done. Checking connectivity… done.

查看克隆下来的文件夹

root@ubuntu:/home/peng/work# lsencryption root@ubuntu:/home/peng/work# cd encryption/ root@ubuntu:/home/peng/work/encryption# ls LICENSE

查看git log

root@ubuntu:/home/peng/work/encryption# git log commit 5e0d6d12afb34a8082c6ef60f34f6e615c99746e Author:一口Linux <10221187+yikoulinux@user.noreply.gitee.com> Date: Tue Dec 21 13:57:19 2021 +0000 Initial commit

拷贝标识符到当前目录

root@ubuntu:/home/peng/work/encryption# ls key.c key.h LICENSE main.c README.md

其中README.md是文档说明,采用Markdown格式撰写。

添加源文件到本地仓库:

root@ubuntu:/home/peng/work/encryption# git add *root@ubuntu:/home/peng/work/encryption# git status On branch master Your branch is up-to-date with origin/master. Changes tobe committed: (use “git reset HEAD <file>…” to unstage) modified: LICENSE new file: README.md new file: key.c new file: key.h new file: main.c Changes not staged for commit: (use “git add <file>…” to update what will be committed) (use “git checkout — <file>…” to discard changes in working directory) modified: .gitignore

执行commit

root@ubuntu:/home/peng/work/encryption# git commit

添加commit 的 log信息【此时编辑工具是vim】

手把手教你如何上传代码到gitee服务器

上载至伺服器:

root@ubuntu:/home/peng/work/encryption# git pushwarning: push.default is unset; its implicit value has changed in Git 2.0 from matching to simple. To squelch this message and maintain the traditional behavior,use: git config –global push.default matching Tosquelch this messageand adopt the new behavior now, use: git config –global push.default simple Whenpush.defaultis set to matching, git will push local branches to the remote branches that already exist withthe same name. Since Git2.0, Git defaults to the more conservative simple behavior, which only pushes the currentbranchto the corresponding remote branch that git pull uses to update the current branch. See git help config and search for push.default for further information. (the simple mode was introduced in Git 1.7.11. Usethe similarmode current instead of simple if you sometimes use older versions of Git) Username for https://gitee.com: yikoulinux Password for https://yikoulinux@gitee.com: Counting objects: 6, done. Compressing objects:100% (6/6), done. Writing objects: 100% (6/6), 2.28 KiB | 0 bytes/s, done. Total 6(delta0), reused 0 (delta 0) remote: Powered by GITEE.COM [GNK-6.2] Tohttps://gitee.com/yikoulinux/encryption.git5e0d6d1..484d5d4 master -> master

其中会要求输出用户名(开头设置的名字yikoulinux)密码,密码输出时不会回显。

最终在gitee上显示结果:

手把手教你如何上传代码到gitee服务器

这样我们就成功的将本地标识符上载至伺服器了。

5. 常用git命令

git clone 工程项目地址 拉工程项目 git pull 拉标识符 git push 提交到仓库 git init 指令初始化两个git仓库 git add .添加文件 git commit -m “注释”提交至仓库。 git remote add origin https://git.oschina.net/你的用户名/工程项目名. git,git push origin master方可完成推送 git checkout master 切换到master分支

6. 如果不想每次都输出用户名密码可以

(1)生成ssh密钥

ssh-keygen -C 7335817@qq.com -t rsa

会在用户目录~/.ssh/下建立相应的密钥文件。 如果是管理员创建在目录/root/.ssh/下。

(2)上载公钥

使用命令cd ~/.ssh进入~/.ssh文件夹,输出

cat id_rsa.pub

关上id_rsa.pub文件,复制其中所有内容。接着访问git页面,点选SSH公钥,标题栏可以随意输出,公钥栏把刚才复制的内容粘贴进去。

手把手教你如何上传代码到gitee服务器

此外,一口君还创建了两个基于Linux的聊天室的开源工程项目, 基功能包括登录、注册登记、公聊、私聊、数据库、数据加密等功能。 其他功能后续会陆续完善。

https://gitee.com/yikoulinux/chat.git

最后欢迎各位给我的开源工程项目点个星!

感谢了!

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务