使用git上传代码到GitHub,git的使用

可以现在github中建好仓库,然后将本地的仓库与github仓库建立连接。
建好GitHub仓库,github上面也有怎么建立本地仓库的连接的方法。
image

如果你没有本地仓库你可以:

echo "# toutiao-publish-admin" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/codingwang-chao/toutiao-publish-admin.git
git push -u origin main

如果已经有本地仓库可以将本地仓库与之建立连接:

git remote add origin https://github.com/codingwang-chao/toutiao-publish-admin.git
git branch -M main
git push -u origin main

还有更笨的方法(不建议使用)
第一步
git clone + 上传地址(GitHub中创建的项目地址)
第二步
将要上传的代码目录中会自动生成一个目录,目录名为GitHub中创建的名称,
将所有代码复制到这个目录中
第三步
cd + 目录名 将git运行在这一层目录
第四步
git add .
第五步
git commit -m "提交信息" (提交的信息是你的项目说明)
第六步
git push -u origin master

如果你没有全局配置用户名和邮箱

你就要配置这些
git config --global user.name "用户名"
git config --global user.password "密码"
git config --global user.email "邮箱"
使用 --global 修饰后设置的全局的用户,如果设置单个项目的用户,可cd到项目根目录下,执行如下命令:

$ git config user.name "Your Name"
$ git config user.email "email@example.com"
posted @ 2021-03-01 15:13  嘿!那个姑娘  阅读(40)  评论(0编辑  收藏  举报