1. Github端
(1)在github创建新的Repository.
(2)复制该库的远程仓库的地址
https://github.com/xxx/xx.git
Notes:保持本地分支和远程仓库分支的一致。
2.本地
(1)在本地文件夹执行git init
,初始化Git仓库。
(2)git remote add origin https://github.com/xxx/xx.git
关联远程仓库。
可能会出现fafal: remote origin already exists.
If origin exists, you can do one of the following:
- remove origin from the remote list via remove command, like so:
git remote remove origin
- update origin pointing URL with set-url, like so:
git remote set-url origin [new-url]
- rename the existing origin handler to something else via rename command:
git remote rename origin [new-name]
How to fix ‘fatal: refusing to merge unrelated histories’ Git error - Here the git command will look something like this:
git pull origin master --allow-unrelated-histories
.
(3)git pull origin main
同步远程仓库和本地仓库。
(2)git add .
添加所有文件至Git仓库
(3)git commit -m ""
提交至Git仓库。
(4)git push origin main
将本地仓库修改(或者添加)的内容提交到远程仓库。
- 每天自动推送脚本