Git上传本地文件到GitHub

想要上传本地文件到GitHub 分两种情况(以下皆是举例,类似公式套用自己的文件即可)

1.第一种本地没有仓库的情况

# 如果本地没有仓库,需要先同步远程仓库的数据
git clone https://github.com/yourname/yourrepository

  

2.第二种本地有仓库,之前做过

# 如果本地有仓库,先添加远程地址,然后切换到仓库目录,添加文件到暂存库
git remote add origin https://github.com/yourname/yourrepository
git add filename
git commit -m "update files"
# 然后将暂存库的文件,推送到远程仓库即可(main是分支)
git push origin main

最后有如图类似完成字样,即上传成功

 

posted @ 2024-07-11 15:50  学python的菜鸟  阅读(1)  评论(0编辑  收藏  举报