git上传至公共或私有github

发布时间 2023-10-10 17:43:34作者: DidierFeng

1. 下载git bash

参考链接:https://git-scm.com/download

2. 创建git的秘钥

git config --global user.name "githubname"
git config --global user.email "githubemail"

ssh-keygen -t rsa -C "githubemail"

其中:githubname是你的名称,githubemail是你的邮箱

3. 添加defaultBranch

[init]
defaultBranch=main

4. 首次创建git提交代码

git init
git add .
git commit -m "test"
git remote add origin 你的git仓库
git push origin main

5. 拉取代码

单独拉取代码:

git fetch 你的github仓库

拉取并且合并:
git pull 你的github仓库
其中:git pull = git fetch + git merge

6. 获取整个远程库

git clone 你的github仓库