上传本地项目到github

来源:互联网 发布:图的广度优先遍历c语言 编辑:程序博客网 时间:2024/05/22 11:39

我们有时需要把本地项目上传到github上进行发布,

具体的设置步骤如下:

hostnamectl set-hostname flask-dev   设置主机名称
ssh-keygen                          # 生成 SSH 公钥cd .ssh/cat id_rsa.pub
git config --global user.email "test@example.com" //设置github邮箱用户名配置git config --global user.name "test"cat ~/.gitconfig

将id_rsa.pub的内容上传到github 添加ssh公钥

首先登陆github, 在ccount Settings-->SSH  Keys 添加ssh

Title: 自己设置title名称

Key:将先前id_rsa.pub中生成的公钥拷贝至此




测试是否github账号连接成功.
ssh -T git@github.com 确认yes连接, 如下表示账号连接成功
Hi dou! You've successfully authenticated, but GitHub does not provide shell access.

在github页面上建立一个新仓库


在本地创建github项目并上传到github仓库中。

# 让 Git 忽略对整个 venv 目录和所有 *.pyc 文件的处理,让 Git 仅处理自己的代码文件vim .gitignore        env/    *.pycmkdir flask-blogcd flask-blog# 创建 README 文件echo "# This is a study demo" >> README.md# 初始化 git 仓库git init# 将刚创建的文件都加入 git 缓冲区git add .# 提交改动文件到 git 仓库git commit -m "first commit"
# 将项目发布到 githubgit remote add origin https://github.com/doudoukongkong/flask-blog.gitgit push -u origin master
 # 将项目发布到 githubgit remote add origin https://github.com/JmilkFan/JmilkFan-s-Blog.gitgit push -u origin master




0 0