Git is a distributed version control software. The same Git warehouse can be distributed to different machines.
The github website provides Git warehouse hosting services, so as long as you register a GitHub account, you can
get a Git remote warehouse for free.
GitHub official website: https://github.com/
1. Configure the local public key in the remote library
github official website-> user icon-> settings-> SSH and FPF keys-> new SSH key
Open the id_rsa.pub under the hidden file .ssh in the root directory,
copy and paste it to the Key
2. Associate remote warehouse
$ git remote add origin git@github.com:flymeawei/testgit.git
3. View remote library information
$ git remote -v
Create and switch to branch main
git check -b main
4. Upload data to the remote library
# '-u' 的意思为以后可以⽤git push 替换 git push origin dev
$ git push -u origin main
5. The remote library updates the local library
$ git pull --rebase origin main
6. Download the source code from the remote library to the local library
$ git clone git@github.com:pythonde/newRepository.git
7. Delete the connection remote library
$ git remote rm origin
example:
➜ ~ ls
公共的 视频 文档 音乐 linuxjihuo2021
模板 图片 下载 桌面 pycharm-2021.3.3
➜ ~ cd 桌面/test
➜ test git:(master) zsh
➜ test git:(master) ls
➜ test git:(master) git checkout -b main
切换到一个新分支 'main'
➜ test git:(main) vi hello.py
➜ test git:(main) ✗ cat hello.py
i = 10
➜ test git:(main) ✗ git remote add origin git@github.com:flymeawei/testgit.git
➜ test git:(main) ✗ git remote -v
origin git@github.com:flymeawei/testgit.git (fetch)
origin git@github.com:flymeawei/testgit.git (push)
➜ test git:(main) ✗ ls
hello.py
➜ test git:(main) ✗ git pull --rebase origin main
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
展开对象中: 100% (5/5), 2.30 KiB | 2.30 MiB/s, 完成.
来自 github.com:flymeawei/testgit
* branch main -> FETCH_HEAD
* [新分支] main