我为了方便,直接把命令行操作接下来带上注释,这样我以后也可以复用
wwyyxx@ubuntu:~$ sudo apt-get install git // 安装git 安装命令都是一样的,如果不成功可以查一下为什么,网上解答都很多了
[sudo] password for wwyyxx:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
git-man liberror-perl
Suggested packages:
git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk
gitweb git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
git git-man liberror-perl
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 5,465 kB of archives.
After this operation, 38.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu focal/main amd64 liberror-perl all 0.17029-1 [26.5 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 git-man all 1:2.25.1-1ubuntu3.2 [884 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 git amd64 1:2.25.1-1ubuntu3.2 [4,554 kB]
Fetched 5,465 kB in 3s (1,834 kB/s)
Selecting previously unselected package liberror-perl.
(Reading database ... 180933 files and directories currently installed.)
Preparing to unpack .../liberror-perl_0.17029-1_all.deb ...
Unpacking liberror-perl (0.17029-1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a2.25.1-1ubuntu3.2_all.deb ...
Unpacking git-man (1:2.25.1-1ubuntu3.2) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a2.25.1-1ubuntu3.2_amd64.deb ...
Unpacking git (1:2.25.1-1ubuntu3.2) ...
Setting up liberror-perl (0.17029-1) ...
Setting up git-man (1:2.25.1-1ubuntu3.2) ...
Setting up git (1:2.25.1-1ubuntu3.2) ...
Processing triggers for man-db (2.9.1-1) ...
wwyyxx@ubuntu:~$ git--version // 查看版本
git--version: command not found
wwyyxx@ubuntu:~$ git -- version
unknown option: --
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>]
wwyyxx@ubuntu:~$ git --version
git version 2.25.1
wwyyxx@ubuntu:~$ ssh-keygen-t rsa -Cwyx18184058696@163.com//创建项目的ssh -key
ssh-keygen-t: command not found
wwyyxx@ubuntu:~$ ssh-keygen -t rsa -Cwyx18184058696@163.com
Generating public/private rsa key pair.
Enter file in which to save the key (/home/wwyyxx/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/wwyyxx/.ssh/id_rsa
Your public key has been saved in /home/wwyyxx/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:8VXPrfb0KOLCktISj8linz+4iQHgw1vo4RwswVfiERE wyx18184058696@163.com
The key's randomart image is:
+---[RSA 3072]----+
| E+. . |
|. . + . o.|
|o. o . . +|
|=.o o . . |
|oO . S . o .|
|=.* . . +.|
| =.. B o . . . o|
| ooBo* o. . . |
| ..o==.o .. |
+----[SHA256]-----+
wwyyxx@ubuntu:~$ /home/wwyyxx/.ssh
bash: /home/wwyyxx/.ssh: Is a directory
wwyyxx@ubuntu:~$ gedit id_rsa.pub
wwyyxx@ubuntu:~$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos
wwyyxx@ubuntu:~$ cd /home/wwyyxx/.ssh
wwyyxx@ubuntu:~/.ssh$ ls // ls命令就是查看文件里面的所有文件
id_rsa id_rsa.pub
wwyyxx@ubuntu:~/.ssh$ gedit id_rsa.pub // gedit命令就是打开,可以编辑的形式
----------------------------------------------------------------------------------------
接下来需要登录GitHub或者gitee,gitlab 自己创建一个仓库,因为我国的原因,咳咳,GitHub有些不稳定所以我选择gitee,方便好用!gitee上连接可以看我的第一篇文章
----------------------------------------------------------------------------------------
wwyyxx@ubuntu:~/.ssh$ git config --global user.name //配置用户名
wwyyxx@ubuntu:~/.ssh$ wyx
Command 'wyx' not found, did you mean:
command 'lyx' from deb lyx (2.3.4.2-2)
command 'nyx' from deb nyx (2.1.0-2)
Try: sudo apt install <deb name>
wwyyxx@ubuntu:~/.ssh$ git config --global user.name wuyixing
wwyyxx@ubuntu:~/.ssh$ git config --global user.email wyx18184058696@163.com//配置邮箱
wwyyxx@ubuntu:~/.ssh$ cd
wwyyxx@ubuntu:~$ cd Desktop
wwyyxx@ubuntu:~/Desktop$ mkdir test//创建test文件
wwyyxx@ubuntu:~/Desktop$ ls
test
wwyyxx@ubuntu:~/Desktop$ cd test
wwyyxx@ubuntu:~/Desktop/test$ git clone https://gitee.com/buaawyx/apollo.git//clone 库到本地
Cloning into 'apollo'...
Username for 'https://gitee.com': buaawyx
Password for 'https://buaawyx@gitee.com':
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 7 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), 2.20 KiB | 2.20 MiB/s, done.
wwyyxx@ubuntu:~/Desktop/test$ cd apollo
wwyyxx@ubuntu:~/Desktop/test/apollo$ ls
README.en.md README.md
wwyyxx@ubuntu:~/Desktop/test/apollo$ cd
wwyyxx@ubuntu:~$ ls
Desktop Documents Downloads Music Pictures Public Templates test_git Videos
wwyyxx@ubuntu:~$ cd Desktop/test
wwyyxx@ubuntu:~/Desktop/test$ ls
apollo
wwyyxx@ubuntu:~/Desktop/test$ mkdir test1
wwyyxx@ubuntu:~/Desktop/test$ cd test1
wwyyxx@ubuntu:~/Desktop/test/test1$ gedit hello.txt//创建一个hello文件用于测试,在里面可以写一些东西以便测试
wwyyxx@ubuntu:~/Desktop/test/test1$ ls
hello.txt
wwyyxx@ubuntu:~/Desktop/test/test1$ git init // 初始化
Initialized empty Git repository in /home/wwyyxx/Desktop/test/test1/.git/
wwyyxx@ubuntu:~/Desktop/test/test1$ git remote add origin https://gitee.com/buaawyx/apollo.git // 添加远程仓库
wwyyxx@ubuntu:~/Desktop/test/test1$ git pull --rebase origin master 获取远程库和本地同步,我认为这里应该是一个实时更新的操作
Username for 'https://gitee.com': buaawyx
Password for 'https://buaawyx@gitee.com':
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 7 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), 2.20 KiB | 2.20 MiB/s, done.
From https://gitee.com/buaawyx/apollo
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
wwyyxx@ubuntu:~/Desktop/test/test1$ git add apollo.txt
fatal: pathspec 'apollo.txt' did not match any files
wwyyxx@ubuntu:~/Desktop/test/test1$ git add hello.txt // 将工作区的hello加到缓存区
wwyyxx@ubuntu:~/Desktop/test/test1$ git commit -m "first commit"//把暂存区的内容加到仓库
[master ef28a0b] first commit
1 file changed, 1 insertion(+)
create mode 100644 hello.txt
wwyyxx@ubuntu:~/Desktop/test/test1$ git push origin master //将仓库的内容推送到gitee上
Username for 'https://gitee.com': buaawyx
Password for 'https://buaawyx@gitee.com':
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 2 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 281 bytes | 281.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-6.2]
To https://gitee.com/buaawyx/apollo.git
fbb4844..ef28a0b master -> master //完成!!!!
wwyyxx@ubuntu:~/Desktop/test/test1$
|