GIT 新手教程 Ubuntu
概述
简单介绍GIT的基本用法。
查看GIT版本
确保已经成功安装git。
$robots@Robots-ubuntu1604:~$ git --version
git version 2.7.4
如果没有git可以使用命令安装
robots@Robots-ubuntu1604:~$ sudo apt install git
建立本地GIT仓库
在文件夹test中使用命令git init,会发现当前文件夹中出现新的文件夹.git
robots@Robots-ubuntu1604:~/test$ git init
Initialized empty Git repository in /home/robots/test/.git/
robots@Robots-ubuntu1604:~/test$ ls -ahil
total 12K
1461536 drwxrwxr-x 3 robots robots 4.0K 7月 7 18:15 .
1438977 drwxr-xr-x 38 robots robots 4.0K 7月 7 18:15 ..
1439654 drwxrwxr-x 7 robots robots 4.0K 7月 7 18:15 .git
然后将新文件夹下面的文件添加到git仓库中,使用命令git add filename。可以使用git add -A添加当前目录下所有的文件。
robots@Robots-ubuntu1604:~/test$ ls -hil
total 4.0K
1453144 drwxrwxr-x 2 robots robots 4.0K 7月 7 18:22 q
1461953 -rw-rw-r-- 1 robots robots 0 7月 7 18:22 q.txt
robots@Robots-ubuntu1604:~/test$ git add q.txt
可以使用git status 查看当前文件夹文件的状态。提示将会添加新的文件q.txt。
robots@Robots-ubuntu1604:~/test$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage<

本文是一篇关于在Ubuntu系统中使用GIT的教程,涵盖了从安装GIT、初始化本地仓库、连接远程GitHub仓库到提交和推送代码的全过程。通过设置用户信息、生成SSH密钥以及处理多项目与多密钥的情况,帮助新手掌握基本的GIT操作。
最低0.47元/天 解锁文章
1153

被折叠的 条评论
为什么被折叠?



