Linux与gitee的连接

当我们在Linux系统下完成代码后,希望能跟在windows操作下一样,将在编译器上写好的代码传送到远端(gitee)上。

这也不难。只需要按以下步骤即可完成。

第一:先在gitee上创建仓库。如何创建?

进入到gitee的主页面,在右上角找到'+'号,就可以看到创建仓库,点击,进入创建仓库页面。

 然后,根据自己所需,填写好基本信息,需要注意的是:

我们最好能将仓库的介绍写得清清楚楚,不要用随便的心态去写。

还有就是初始化仓库等一系列操作:

在初始化仓库时,可以选择自己使用的语言,而开源许可证,先阶段可以选择第一个,这个不重点讲解。在设置模板,选择第一个,分支模型选择单分支模型。

创建成功后,我们就可以在Linux下进行操作啦!

我们先复制我们的链接:

选择HTTPS,其它的不用管,正常学习计算机的,不是很需要管另外几个。 

第二:在Linux中进行三板斧。

1.在我们存放代码文件的目录中,使用指令:git clone 你的链接

[wjmhlh@VM-12-9-centos lesson9]$ ll
total 28
-rw-rw-r-- 1 wjmhlh wjmhlh  107 Nov 13 15:34 Makefile
-rw-rw-r-- 1 wjmhlh wjmhlh  391 Nov 13 15:34 process.c
-rw-rw-r-- 1 wjmhlh wjmhlh  148 Nov 13 15:34 process.h
-rwxrwxr-x 1 wjmhlh wjmhlh 8712 Nov 13 15:34 Processon
-rw-rw-r-- 1 wjmhlh wjmhlh   72 Nov 13 14:56 test.c
[wjmhlh@VM-12-9-centos lesson9]$ git clone https://gitee.com/jiejiejieming/test_code.git
Cloning into 'test_code'...
Username for 'https://gitee.com': (这里输入仓库的账号)
Password for 'https://18575788117@gitee.com': (输入仓库的密码)

//显示下面内容,便证明连接成功
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.

//输入成功后,便可以看到我们的test_code
[wjmhlh@VM-12-9-centos lesson9]$ ll
total 32
-rw-rw-r-- 1 wjmhlh wjmhlh  107 Nov 13 15:34 Makefile
-rw-rw-r-- 1 wjmhlh wjmhlh  391 Nov 13 15:34 process.c
-rw-rw-r-- 1 wjmhlh wjmhlh  148 Nov 13 15:34 process.h
-rwxrwxr-x 1 wjmhlh wjmhlh 8712 Nov 13 15:34 Processon
-rw-rw-r-- 1 wjmhlh wjmhlh   72 Nov 13 14:56 test.c
drwxrwxr-x 3 wjmhlh wjmhlh 4096 Nov 13 21:33 test_code
 

2.当我们进入test_code的时候,就会看见与仓库相对于的目录或文件了

[wjmhlh@VM-12-9-centos lesson9]$ cd test_code
[wjmhlh@VM-12-9-centos test_code]$ ll
total 20
-rw-rw-r-- 1 wjmhlh wjmhlh 9592 Nov 13 21:33 LICENSE
-rw-rw-r-- 1 wjmhlh wjmhlh  843 Nov 13 21:33 README.en.md
-rw-rw-r-- 1 wjmhlh wjmhlh  932 Nov 13 21:33 README.md

[wjmhlh@VM-12-9-centos test_code]$ ls -al
total 36
drwxrwxr-x 3 wjmhlh wjmhlh 4096 Nov 13 21:33 .
drwxrwxr-x 3 wjmhlh wjmhlh 4096 Nov 13 21:32 ..
drwxrwxr-x 8 wjmhlh wjmhlh 4096 Nov 13 21:33 .git
-rw-rw-r-- 1 wjmhlh wjmhlh  270 Nov 13 21:33 .gitignore
-rw-rw-r-- 1 wjmhlh wjmhlh 9592 Nov 13 21:33 LICENSE
-rw-rw-r-- 1 wjmhlh wjmhlh  843 Nov 13 21:33 README.en.md
-rw-rw-r-- 1 wjmhlh wjmhlh  932 Nov 13 21:33 README.md

[wjmhlh@VM-12-9-centos test_code]$ 
 

这里需要解释的是:

其中的.git,就是本地仓库,其实本地仓库,指的就是我们在自己电脑上,存放代码的一个目录。

然后.gitignore,见名知意,在这个文件中存放的所有后缀名,如果我们要上传的文件或目录的后缀名被包括在了.gitignore里面,那么这个文件或目录就不会上传。

我们可以打开来看看:

3.把需要上传的文件或目录,弄到当前文件夹中,也就是test_code这个目录中。

[wjmhlh@VM-12-9-centos test_code]$ cp ../*.c .
[wjmhlh@VM-12-9-centos test_code]$ cp ../*.h .
[wjmhlh@VM-12-9-centos test_code]$ ll
total 32
-rw-rw-r-- 1 wjmhlh wjmhlh 9592 Nov 13 21:33 LICENSE
-rw-rw-r-- 1 wjmhlh wjmhlh  391 Nov 13 21:41 process.c
-rw-rw-r-- 1 wjmhlh wjmhlh  148 Nov 13 21:41 process.h
-rw-rw-r-- 1 wjmhlh wjmhlh  843 Nov 13 21:33 README.en.md
-rw-rw-r-- 1 wjmhlh wjmhlh  932 Nov 13 21:33 README.md
-rw-rw-r-- 1 wjmhlh wjmhlh   72 Nov 13 21:41 test.c
 

4.当完成第3步的时候,便可以进行三板斧了!

三板斧就是:add,commit和push

[wjmhlh@VM-12-9-centos test_code]$ git add .
[wjmhlh@VM-12-9-centos test_code]$ ll
total 32
-rw-rw-r-- 1 wjmhlh wjmhlh 9592 Nov 13 21:33 LICENSE
-rw-rw-r-- 1 wjmhlh wjmhlh  391 Nov 13 21:41 process.c
-rw-rw-r-- 1 wjmhlh wjmhlh  148 Nov 13 21:41 process.h
-rw-rw-r-- 1 wjmhlh wjmhlh  843 Nov 13 21:33 README.en.md
-rw-rw-r-- 1 wjmhlh wjmhlh  932 Nov 13 21:33 README.md
-rw-rw-r-- 1 wjmhlh wjmhlh   72 Nov 13 21:41 test.c
[wjmhlh@VM-12-9-centos test_code]$ git commit -m '测试代码'

//这里需要注意的是,同样的,我们对代码的介绍一定一定不能随便写

//当出现下面这段信息,证明,commit成功
[master c96499a] 测试代码
 3 files changed, 36 insertions(+)
 create mode 100644 process.c
 create mode 100644 process.h
 create mode 100644 test.c
[wjmhlh@VM-12-9-centos test_code]$ ll
total 32
-rw-rw-r-- 1 wjmhlh wjmhlh 9592 Nov 13 21:33 LICENSE
-rw-rw-r-- 1 wjmhlh wjmhlh  391 Nov 13 21:41 process.c
-rw-rw-r-- 1 wjmhlh wjmhlh  148 Nov 13 21:41 process.h
-rw-rw-r-- 1 wjmhlh wjmhlh  843 Nov 13 21:33 README.en.md
-rw-rw-r-- 1 wjmhlh wjmhlh  932 Nov 13 21:33 README.md
-rw-rw-r-- 1 wjmhlh wjmhlh   72 Nov 13 21:41 test.c
[wjmhlh@VM-12-9-centos test_code]$ git push

//当出现下面这段信息,证明push成功
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Username for 'https://gitee.com': (输入仓库账号)
Password for 'https://18575788117@gitee.com': (输入仓库密码)

//当输入账号密码后,出现下面这段信息,证明,上传成功
Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 894 bytes | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/jiejiejieming/test_code.git
   08c322e..c96499a  master -> master
 

最后,我们来打开仓库看看,我们的代码:

这样,我们就能够在Linux下,也能对代码进行上传啦!!!

最后提一下一些命令:

git pull——对gitee里面的代码传回,因为可能我会在gitee里面直接修改上传后的代码,等什么时候,我在Linux里面更新代码,想要上传的时候,两者的原本的代码不匹配,那么就不能上传。所有需要pull回来。

git log——查看上传日志

git rm 和git mv   对上传的文件进行删除或移动

git status——查看仓库状态。

  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

山雾隐藏的黄昏

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值